Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extract a number from string 1

Status
Not open for further replies.

emergencyplan

Technical User
Aug 19, 2003
34
GB
Hello everyone,

I've looked but cannot find.....I have a string of numbers in the following format 10,12,13,200. In this example I would like to use the 13 .i.e. the third integer in the string. Also, this integer could range from 0-15000 and therefore I need to be flexible when extracting the string.

Any help gratefully recieved,

thanks

Laurence
 
Look up the Split() function - does just what you want

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Sorry - hit submit too quickly:

myArray = Split(myList,",")
myThirdNum = myArray(2)

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
>myThirdNum = myArray(2)

Just for clarity...

shouldn't that be
Code:
myintThirdNum = cint(myArray(2))

[poke]

Take Care

Matt
If at first you don't succeed, skydiving is not for you.
 
OK, if the max for this number is 15.000, an Integer variable will still do it (goes to 32k):

Dim i,x,MyVal as Integer
Dim helper as String
helper=YourString 'don't want to overwrite your String!
For i=1 to 2
x=Instr(1,helper,",")
helper=Right(helper,Len(helper)-x)
Next i
x=Instr(1,helper,",")
helper=Left(helper,x-1)
MyVal=Cint(helper)

Does that do what you need?
[lightsaber]
MakeItSo



Andreas Galambos
EDP / Technical Support Specialist
Bowne Global Solutions Wuppertal, Germany
(andreas.galambos@bowneglobal.de)
HP:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top