Experts Exchange connects you with the people and services you need so you can get back to work.
Dim i As Long = CLng(yourStringVariableHere)
Open in new window
Dim i As Long
If Long.TryParse(yourStringVariableHere, i) Then
' ... do something with "i" ...
MessageBox.Show(yourStringVariableHere, "Invalid Long")
Private Function StripToInt(ByVal Data As String)
Dim NegativeSign As Boolean = False
Dim Ch As Char
For i = 1 To Len(Data)
Ch = Mid$(Data, i, 1)
If "0" <= Ch And Ch <= "9" Then
StripToInt = StripToInt & Ch
ElseIf Ch = "-" Then
If Len(StripToInt) = 0 Then
NegativeSign = True
If NegativeSign And Len(StripToInt) Then
StripToInt = "-" & StripToInt
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.
One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.