Monday, May 24, 2010

How to Convert string "610 8345" into Integer in VB.Net or C#?

Try any of this code


Dim i as integer=Convert.ToInt32("your number as string")


or


Dim i as integer=Val("your number as string")


or


Dim i as integer=CInt("your number as string")

How to Convert string "610 8345" into Integer in VB.Net or C#?
'i noticed a space between the 0 and the 8


Dim String1 As String = "6108345"


Dim IntConvert As Integer





IntConvert = CInt(String1)





if there's a space, you'll have to add this code


Const space As Char = " "c


Dim resultArray As String() = string1.Remove(Val(space))





Hope this helps





R3dm0


No comments:

Post a Comment