Click here to Skip to main content
15,917,060 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all , i have string like t

dim k as string
k="00004"

i want to add +1 with that value and get it "00005"

how do this in vb.net his
Posted

Better use an int, and format it with ToString().

VB
Dim k As String = "00004"
Dim kValue As Integer = Integer.Parse(k) ' kValue = 4
kValue += 1                              ' kValue = 5
k = kValue.ToString("00000")             ' k = "00005"
 
Share this answer
 
v3
Comments
VJ Reddy 22-Apr-12 11:12am    
Good answer. 5!
Nelek 22-Apr-12 18:02pm    
+5
Don't.
Keep the value as an integer, and convert it to a string when you actually need it as a string, and not before.
VB
Dim i As Integer = 4
Dim str As String = i.ToString("00000")
 
Share this answer
 
Comments
VJ Reddy 22-Apr-12 11:12am    
Good advice. 5!
Dim a as integer = 5
Dim as string = cstr(a)
 
Share this answer
 

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