0

Would any one help me to solve the problem???

for example: 12345/abc123

I want to divide the above string into two value,

- 12345
- abc123

I want to know how can the program recognize the value in each digit???
And how can the program recognize the "/" to divide into two string???

Thank you very much~~

3
Contributors
2
Replies
3
Views
11 Years
Discussion Span
Last Post by Comatose
0

Hi,

use instr to find the '/'
then left and right to get the two halves.

Dim x As String
    Dim slash As Integer
    Dim lCode, rCode As String
    
    x = "1234/abc123"
    slash = InStr(1, x, "/")
    
    If slash = 0 Then
        MsgBox "No Slash in code"
        Exit Sub
    End If
    
    lCode = Left$(x, slash - 1)
    rCode = Right$(x, Len(x) - slash)
    
    Label1 = lCode
    Label2 = rCode
    Label3 = x
0

Split.

' /* Specifically For Yomet ;) */
dim str as string
dim parts() as string
dim part1 as string
dim part2 as string

str = "12345/abc123"
parts = split(str, "/")
part1 = parts(0)
part2 = parts(1)

Now the variable part1, will be 12345, and the variable part2 will be abc123.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.