|
-
Oct 2nd, 2002, 12:54 PM
#1
Thread Starter
Hyperactive Member
Easy string question **Resolved**
I have a string wich contain two number separated by an undercscore(_). I would like to extract both numbers separatly. Their lenght is variable so I can't use Right and Left functions. Any ideas ?
Thanks
Last edited by maxl; Oct 2nd, 2002 at 01:04 PM.
COBOL sa suce !!!
-
Oct 2nd, 2002, 12:56 PM
#2
Addicted Member
Check the instr() function!
-
Oct 2nd, 2002, 12:57 PM
#3
SPLIT!!!
VB Code:
Dim arr() As Stirng
arr = Split("123_456","_")
debug.print arr(1)
debug.print arr(2)
-
Oct 2nd, 2002, 12:57 PM
#4
Frenzied Member
Code:
num=00123_7478
Number1=left(num,InStr(1,num,"_")-1)
Number2=Mid(num,InStr(1,num,"_")+1)
-
Oct 2nd, 2002, 12:57 PM
#5
PowerPoster
Try this:
VB Code:
Dim intPos As Integer
Dim strValue As String
strValue = "213_12837"
intPos = InStr(1, strValue, "_")
Debug.Print Left(strValue, intPos - 1)
Debug.Print Mid(strValue, intPos + 1)
-
Oct 2nd, 2002, 01:04 PM
#6
Thread Starter
Hyperactive Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|