Click here to Skip to main content
15,890,185 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can I count using static variables in vb 2005 or vb 2008? As an example There is a value that entered previously as a Supplier no = SUP0010. I want to get the next Supplier no as 'SUP0011' by automatically counting the existing last entered Supplier No.
Posted

1 solution

Yes you can do this using a static or a class level instance variable.
Just set this variable to 0 initially. Then use substring to get the last four characters of the current supplier no. Convert this into an integer and increment and store it in the variable.

You can then use the variable to get the next supplier no by appending SUP to the number and padding the integer by using the PadLeft function[^].
 
Share this answer
 
Comments
Chiranthaka Sampath 22-Oct-11 12:45pm    
What is this sub-string is it like to be like the concatenation in vb?
Abhinav S 23-Oct-11 0:47am    
Substring is like the Mid command in VB.
Chiranthaka Sampath 22-Oct-11 12:48pm    
If I used a Mask text Box instead of how can I do that? This mask text box include the 'SUP' characters as its text proper tie's value!
Abhinav S 23-Oct-11 0:48am    
You can do something similar in the masked control - take out the last 4 values and use them as the key.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900