Setting Password TextBox Minimum & Maximum Size

Tyecom

Well-known member
Joined
Aug 8, 2007
Messages
78
Programming Experience
Beginner
I have a textbox that is serving as a password field. I want the user to put a minimum of 6 character and a maximum of 10. Is there a way of doing this in vb.net? I also would like it to become disabled after 6 consecutive logon attempts. Thanks in advance.
 
Last edited:
hi

for validating the texbox something like this could help:

VB.NET:
If txtTest.Text.Trim.Length < 6 Or txtTest.Text.Trim.Length > 10 Then
  MessageBox.Show("something")
End If

as for the disabling feature after several attemps you can try the following:

1-declare a global variable - integer example: Din hitCount as Integer

2-every time the user presses the button, increment the value
example: hitCount = hitCount + 1

3- then check if the "hitCount" is greater then 6 for you to acctually accept the login details

Hope that helps ;)
 
This doesn't work. Everytime I enter any number, the message box pop up. I think this statement is saying any number less than 6, therefore, when I type in one character, the message comes up. I think we're close, but not yet. Any other suggestions.
 
just change things around a little bit:
VB.NET:
If txtTest.Text.Trim.Length >= 5 AndAlso txtTest.Text.Trim.Length <= 10 Then
  MessageBox.Show("Valid Length")
Else
  MessageBox.Show("Not of valid length")
End If
This will only show a message box if the number of characters typed in txtTest is 5, 6, 7, 8, 9, or 10.
 
Back
Top