I am trying to split a single line of data into three separate parts so that they can be displayed in different textboxes. The data looks like this:


The code that I tried is:

Dim arrayLines() As String
Dim record As String

record = Subs.Text
arrayLines = record.Split("_")

TextBox1.Text = arrayLines(0)
TextBox2.Text = arrayLines(1)

I don't seem to have much luck, I don't even get an error message when I click on the button. Any suggestions..?

Edited 4 Years Ago by collin_ola: typo

hello !
please use this code this will solve your prob :)

Dim str As String
        Dim strArr() As String
        Dim count As Integer
        str = txtUsername.Text ' txtbox having txt you wana split.
        strArr = str.Split("_")
        For count = 0 To strArr.Length - 1
            If txt1.Text = "" Then
                txt1.Text = strArr(count).ToString

                If txt2.Text = "" Then
                    txt2.Text = strArr(count).ToString
                    If txt3.Text = "" Then
                        txt3.Text = strArr(count).ToString
                    End If
                End If
            End If


if your prob is solved then pleas mark this thread solved and also dont forget to add reputation .


Edited 4 Years Ago by M.Waqas Aslam: n/a

This question has already been answered. Start a new discussion instead.