Solved

Parsing

Posted on 2004-09-10
3
131 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

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 …
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
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…

734 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