Sérgio Wilker Sérgio Wilker - 6 months ago 187
Vb.net Question

How to Split Strings in Textboxes with Delimiters

I would like clicking the button would like the strings of the first textbox to divide to the others using a delimiter. I don't have idea how to do this.

enter image description here

Answer Source

A minimalistic solution using String.Split():

Dim splitResult as String()

splitResult = textBoxIn.Text.Split(":")
textBoxOut1.Text = splitResult(0)

splitResult = splitResult(1).Split("-")
textBoxOut2.Text = splitResult(0)
textBoxOut3.Text = splitResult(1)

String.Split() splits first the string from textBoxIn("Word:Number-Div") with ":" creating an array with {"Word", "Number-Div"}. After that the second substring("Number-Div") is split with "-" creating an array with {"Number", "Div"}.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download