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
Printable View
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
Check the instr() function!
SPLIT!!!
VB Code:
Dim arr() As Stirng arr = Split("123_456","_") debug.print arr(1) debug.print arr(2)
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)
Code:
num=00123_7478
Number1=left(num,InStr(1,num,"_")-1)
Number2=Mid(num,InStr(1,num,"_")+1)
Ok thanks everyone