Hi everyone

I have a question about vb.net

I have a textbox

and so on ....

I want to make my program do this:
if I execute the button it must do this:
it must take each line of the textbox apart.
then split that line from |


dim ex() as string

ex = split(textbox1.text,vbcrlf)

ex(0) = 145|145
ex(1) = 145|859
(trying to make an For Next function)

x = 145 and y = 145
execute timer1

loops back to ex(1)
x=145 and y = 859
execute timer1

and loops again (till textbox1 is done)

Thanks in advance <3

commented: Bite Me. Next time mark your thread as solved. -2
Member Avatar


Heres an example that may give you some ideas.

Public Class Form1
    Private TextBoxArray() As String
    Private TimerIndex As Integer

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        TextBoxArray = TextBox1.Text.Split(CChar(vbCrLf))
        TimerIndex = 0
    End Sub

    Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        If TextBoxArray Is Nothing OrElse TimerIndex < LBound(TextBoxArray) OrElse TimerIndex > UBound(TextBoxArray) Then
            Exit Sub
        End If

        Dim StringPosition As String() = TextBoxArray(TimerIndex).Split(CChar("|"))

        If StringPosition.GetLength(0) = 2 AndAlso IsNumeric(StringPosition(0)) AndAlso IsNumeric(StringPosition(1)) Then
            Label1.Text = "x:" & StringPosition(0) & "  y:" & StringPosition(1)
        End If

        TimerIndex += 1
    End Sub
End Class

See if this helps.

Dim arTemp() As String = Nothing '// Array to .Split each TextBox line.
        For Each txtLine As String In TextBox1.Lines '// loop thru all lines.
            arTemp = txtLine.Split("|"c) '// .Split line.
            For Each itm As String In arTemp '// loop thru arrays of current line.
                MsgBox(itm) '// display results.

>>(trying to make an For Next function)
A For/Next is just a "loop", unless you meant to have a Function w/a For/Next loop in it.