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~~

Recommended Answers

All 2 Replies

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.