"If Not" Problem

superstud101

Member
Joined
May 27, 2008
Messages
7
Programming Experience
Beginner
Hi i have this code to check if the user has put the right amount of caricatures in but it come back with "ID's Are Wrong Size" every time

VB.NET:
[COLOR="Blue"]Const[/COLOR] ProfileID_Len = 23
[COLOR="Blue"]Const[/COLOR] DeviceID_Len = 59
[COLOR="Blue"]Const[/COLOR] Console_Len = 14

[COLOR="Blue"]If Not[/COLOR] TextBox2.Text.Length > ProfileID_Len [COLOR="Blue"]And[/COLOR] _
        TextBox3.Text.Length > DeviceID_Len [COLOR="Blue"]And[/COLOR] _
        TextBox4.Text.Length > Console_Len [COLOR="Blue"]Then[/COLOR]
        TextBox1.Text = TextBox1.Text & vbCrLf & "ID's Are Wrong Size"
        TextBox1.Select(TextBox1.Text.Length, 0)
        TextBox1.ScrollToCaret()
        [COLOR="Blue"]Return[/COLOR]
[COLOR="Blue"]End If[/COLOR]

Any help you can offer would be great thank you
 
Try taking out the 'Not'
VB.NET:
Const ProfileID_Len As Integer = 23
Const DeviceID_Len As Integer  = 59
Const Console_Len As Integer  = 14

If TextBox2.Text.Length > ProfileID_Len AndAlso _
        TextBox3.Text.Length > DeviceID_Len AndAlso _
        TextBox4.Text.Length > Console_Len Then
        TextBox1.Text = TextBox1.Text & vbCrLf & "ID's Are Wrong Size"
        TextBox1.Select(TextBox1.Text.Length, 0)
        TextBox1.ScrollToCaret()
        Return
End If
 
As JuggaloBrotha said, take out the Not or you can encase all the comparisons in () like

If Not (TextBox2.Text.Length > ProfileID_Len And _
TextBox3.Text.Length > DeviceID_Len And _
TextBox4.Text.Length > Console_Len) Then

Also, I believe the word you are looking for is characters, not caricatures. Caricatures are drawings that accentuate a person's most prominent feature for the sake of humor.
 
Back
Top