Click here to Skip to main content
15,903,201 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hai what is code that prevent user to given number less than 8 in the text box. If the user give less then 8 number then message box
box will appear which show Minimum Number is 8. Here is my code

VB
Private Sub btnregister_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnregister.Click
 If TELEPHONETextBox.Text.Trim.Length = 0 Then
            MsgBox("Please Enter Phone Number", MsgBoxStyle.Question)
            Me.TELEPHONETextBox.Focus()
        ElseIf Not Decimal.TryParse(Me.TELEPHONETextBox.Text, number) Then
            MsgBox("Please Enter A Number Only In Telephone Text Box.",   MessageBoxButtons.OK)
            Me.TELEPHONETextBox.Select()
 End If

End Sub
Posted
Updated 11-Sep-11 7:52am
v3
Comments
Sergey Alexandrovich Kryukov 11-Sep-11 23:45pm    
What does it mean: "less then 8 numbers"?
--SA

1 solution

just add an ElseIf(number < 10000000) Then after your other ElseIf
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 11-Sep-11 23:45pm    
I had trouble to understand what's "less then 8 numbers". If this really means "less then 8 decimal digits", this answer is correct and the simplest one. My 5.
--SA
Simon Bang Terkildsen 12-Sep-11 0:38am    
Thank you, I think I automatically read "Minimum Number is 8" as "At least 8 digits" because phone numbers here in Denmark is 8 digits.
Sergey Alexandrovich Kryukov 12-Sep-11 12:45pm    
Good guess indeed. OP recommended to formulate requirements thoroughly.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900