Discussion Locked

Split String

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Dear all,
I want to split a string into twoparts.
How to do it?
For example, If I assigned variable called usrnm having string "QWUS\M0392".
But I want to split into two parts or I need only "M0392" from the string.How can I get it?
Will Mid or Replace function help for this?
Please help me!
Thanks in advance!

2 replies

by nz_justice

use left and right

below is an example, I have outputted the result to two lables . lbl1 and lbl2.

Dim b As String
Dim c As String

b = 12345678
c = 12345678

Left(b, 4)
Right(c, 4)

lbl1.Text = Left(b, 4)
lbl2.Text = Right(c, 4

by mcaris

I suggest usage of split function it's very simple and I discovered it recently :(. How could I live without it?

Dim stringToSeparate as string
stringToSeparate="Something\somethingElse"

Dim stringArray() as string
strinArray = split(stringToSeparate,"\")

msgbox(StringArray(0))
msgbox(StringArray(1))

Here U go.

This discussion is closed to new replies.