Solved

Parsing

Posted on 2004-09-10
3
127 Views
Last Modified: 2010-04-23
i want to parse string value into integer how can i do
0
Comment
Question by:ahmadfuwad
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video discusses moving either the default database or any database to a new volume.

706 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now