Solved

Parsing

Posted on 2004-09-10
3
136 Views
Last Modified: 2010-04-23
i want to parse string value into integer how can i do
0
Comment
Question by:ahmadfuwad
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 19

Accepted Solution

by:
drichards earned 20 total points
ID: 12024574
Depends on the string.  The simplest approach is to use Integer.Parse:

    val = Integer.Parse(str)

where val is the integer variable and str is the string variable.
0
 
LVL 3

Expert Comment

by:RacinRan
ID: 12026813
Or you could use the old school VB 6 approach of:

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.

0
 

Expert Comment

by:jerrycsakanyjr
ID: 12027750
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
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question