ahmadfuwad
asked on
Parsing
i want to parse string value into integer how can i do
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try this
on error goto badstring
dim myInt as integer
dim myStr as string
myStr= "you string"
myint = asc(myStr)
msgbox(myint)
badstring:
msgbox("Invalid Characters")
exit sub
on error goto badstring
dim myInt as integer
dim myStr as string
myStr= "you string"
myint = asc(myStr)
msgbox(myint)
badstring:
msgbox("Invalid Characters")
exit sub
val = CInt(str)
but either way ... I would do this in a Try Catch block and add a catch:
Catch ex as InvalidCastException
This way you'll know an error occurred trying to parse the string in case it's not a valid integer and you can provide specific feedback to the user, if this is where it's coming from.