0

I have some picture named like this . (like "2.jpeg", "1234.gif" etc.) how can I get the integer from the string?

I mean, is there something like the C function:

sscanf(myString,"%d", myInteger);

thanks

Alessandro

1
  • Which language are you using? Visual Basic or Visual Basic .NET? Please tag your question as appropriate. Commented Sep 23, 2010 at 21:51

1 Answer 1

1

You will need to remove the non-numeric portion and then call TryParse.

Dim numericPortion As String
Dim result As Integer

numericPortion = myString.Substring(0, myString.IndexOf('.'))
If (Not Int32.TryParse(numericPortion, ByRef result)) Then
    ''// Handle Error
Else
    ''// Use Result
End If
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.