CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: error checking

  1. #1
    Join Date
    Nov 2001
    Posts
    6

    error checking

    ok i have the following line of code

    Do While intBase < 2 Or intBase > 9

    MsgBox("Error, Try Again")

    intBase = txtBase.Text

    Loop

    i can seem to get the program to pause and let the user enter another set of data. can anyone help me out with my problem?

  2. #2
    Join Date
    Oct 2002
    Location
    Växjö, Sweden
    Posts
    225
    Well your code might work if you find a user that i fast enough to change the value of the textbox before the loop gets back to that msgbox.

    Just kidding.

    Is it possible for you to code this on any Event? For example the Changed event or the Validating event?

    /Leyan

  3. #3
    Join Date
    Nov 2001
    Posts
    6
    i just want the user to enter the new data. I just dont know how to do that. To get the program to actually let the user enter the data and pause. Any suggestions?

  4. #4
    Join Date
    Oct 2002
    Location
    Växjö, Sweden
    Posts
    225
    I'm not sure about what you mean, but if you use a code similar to the one below you will prompt the user when the textbox gets validated.

    Code:
    Private Sub TextBox1_Validating(ByVal sender As Object, _
        ByVal e As System.ComponentModel.CancelEventArgs) Handles TextBox1.Validating
        If IsNumeric(TextBox1.Text) Then
            If CInt(TextBox1.Text) < 2 Or CInt(TextBox1.Text) > 9 Then
                MsgBox("Eyyy, wrong number!")
            End If
        End If
    End Sub
    /Leyan

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

Featured