| | |
Textbox Validation giving Error
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Oct 2008
Posts: 17
Reputation:
Solved Threads: 0
I'm trying to validate my textbox so that the user must enter a Table Number between 1 and 20. The click event of the exit button checks this and if invalid input, displays a message box. It works for all numbers except 3-9 where it displays the warning even though it is in range. Anyone see where I'm going wrong?
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Public Class Form1 Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click If (txtTableNo.Text >= "1" And txtTableNo.Text <= "20") Then Me.Close() Else MessageBox.Show("Table Number must be between 1-20", "Warning") End If End Sub Private Sub txtTableNo_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtTableNo.KeyPress If (e.KeyChar < "0" OrElse e.KeyChar > "9") _ AndAlso e.KeyChar <> ControlChars.Back Then e.KeyChar = "" Beep() End If End Sub End Class
![]() |
Similar Threads
- Sign Up Form into Database (ASP.NET)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Reservation System Help using VB 6
- Next Thread: Text box differences
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age append application basic beginner birth bmp calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver subroutine table tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





