Solved

Parsing

Posted on 2004-09-10
3
129 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

Free Tool: Site Down Detector

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.

Question has a verified solution.

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

Suggested Solutions

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

820 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