elcabronel
elcabronel

Reputation: 25

How to split textbox value then display splitted value on label

How to split a text box (delimited by "-") value then display the split values on two labels?

Heres my code:

    Dim s As String
    Dim substring As String
    Dim sp() As String

    s = txtTime1.Text 'this text box contains value (08:00-17:41)
    sp = s.Split("-")

    For Each substring In sp
        txtTimeIn.Text = substring
        txtTimeOut.Text = substring
    Next

My problem is txtTimeIn and txtTimeOut displays only value '17:41'. Thank you so much in advance.

Upvotes: 1

Views: 10173

Answers (1)

Thejaka Maldeniya
Thejaka Maldeniya

Reputation: 1076

Try this:

Dim s As String
Dim substring As String
Dim sp() As String

s = txtTime1.Text 'this text box contains value (08:00-17:41)
sp = s.Split("-")

txtTimeIn.Text = sp(0)
txtTimeOut.Text = sp(1)

Upvotes: 1

Related Questions