-1

Hi everyone

I have a question about vb.net

I have a textbox

textbox:
145|145
145|859
146|745
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 |

Example:

dim ex() as string
145|145
145|859

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

Votes + Comments
Bite Me. Next time mark your thread as solved.
3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by codeorder
0

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
        Timer1.Stop()
        TextBoxArray = TextBox1.Text.Split(CChar(vbCrLf))
        TimerIndex = 0
        Timer1.Start()
    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
            Timer1.Stop()
            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
0

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.
            Next
        Next

>>(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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.