Note from mod: Thread is cross-posted at XVBT.
Hi everyone
I have written a function which is a loop and is similar to old Val() function, I just wanna loop through all characters of an input string and return the numbers:
It won't work and I get errors also I do believe there's a better way to compare if input is between 0 and 9?
Any idea?
Hi everyone
I have written a function which is a loop and is similar to old Val() function, I just wanna loop through all characters of an input string and return the numbers:
Visual Basic:
Private Function GetStrVal(ByVal InputString As String) As Integer
GetStrVal = Nothing
For MyLoop As Integer = 1 To InputString.Length
If InputString.Substring(MyLoop - 1, 1) = 0 Or _
InputString.Substring(MyLoop - 1, 1) = 1 Or _
InputString.Substring(MyLoop - 1, 1) = 2 Or _
InputString.Substring(MyLoop - 1, 1) = 3 Or _
InputString.Substring(MyLoop - 1, 1) = 4 Or _
InputString.Substring(MyLoop - 1, 1) = 5 Or _
InputString.Substring(MyLoop - 1, 1) = 6 Or _
InputString.Substring(MyLoop - 1, 1) = 7 Or _
InputString.Substring(MyLoop - 1, 1) = 8 Or _
InputString.Substring(MyLoop - 1, 1) = 9 Then
GetStrVal = GetStrVal + InputString.Substring(MyLoop - 1, 1)
End If
Next
End Function
Any idea?
Last edited by a moderator: