Results 1 to 3 of 3

Thread: [RESOLVED] [2008] User input data from textbox into an array

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2009
    Posts
    10

    Resolved [RESOLVED] [2008] User input data from textbox into an array

    I'm trying to make a program where user can input data from a textbox into an array and when the user hit the enter key, it compare it to a data grab from a text file. Here is my code so far:

    Private Sub TextBox_KeyDown(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox.TextChanged
    Dim input As String
    Dim KeyCode As Integer

    input = CStr(TextBox.Text)
    If KeyCode = 13 Then
    If InStr(1, varia3, input, vbTextCompare) <> 0 Then golden = True
    If golden = True Then msgbox("match")
    If golden = False Then msgbox("mismatch")
    End If
    End Sub

    I got the part where the program can graph data from text file and put it into an array called "varia3". The part I could not get is allowing user to enter data into the textbox. When I run the program, the sec I try to enter a letter or number into the textbox the program ended.

  2. #2
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,950

    Re: [2008] User input data from textbox into an array

    Use the KeyDown event;

    Code:
        Private Sub TextBox1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) _
        Handles TextBox1.KeyDown
            If e.KeyCode = Keys.Enter Then
                If varia3 = TextBox1.Text Then
                    MsgBox("match")
                Else
                    MsgBox("mismatch")
                End If
            End If
        End Sub

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2009
    Posts
    10

    Re: [2008] User input data from textbox into an array

    This code seems a lot better, but it still won't allow user to enter data. When I ran the program, the sec I enter a letter or numbers the program ended.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width