Results 1 to 5 of 5

Thread: Text Box validation problem!!!!!

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2004
    Location
    Ireland
    Posts
    23

    Text Box validation problem!!!!!

    Hi,

    Im trying to validate a txt box,

    If txtoverdraft.Text = "No", I want it so that any instance of no e.g. No, nO, no, NO what would I use here?

    VB Code:
    1. If txtoverdraft.Text = "No" And txtbalance.Text < 0 Then
    2.  
    3. 'if its not at the end of the file
    4. If (Not datCities.Recordset.EOF) And (Not datCities.Recordset.EOF) Then
    5.  
    6.         'Message box
    7.         MsgBox "Overdraft not available for this client, Please enter balance greater than 0"
    8.        
    9.         txtbalance.Text = ""
    10.        
    11.         'Doesn't save
    12.         Action = 0
    13.        
    14.         txtbalance.SetFocus
    15.  
    16. End If
    17. End If

    Thanks joePC

  2. #2
    Lively Member
    Join Date
    Feb 2003
    Posts
    117
    Code:
    If UCase(txtoverdraft.Text) = "NO"
    Which compares them both as caps. With the second condition, you should really test it as a number, because at the moment it is a string comparison

    Code:
    CInt(txtbalance.Text) < 0 Then

  3. #3
    Frenzied Member
    Join Date
    May 2003
    Location
    So Cal
    Posts
    1,564
    Could also use IsNumeric

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Mar 2004
    Location
    Ireland
    Posts
    23
    VB Code:
    1. If Not UCase(txtoverdraft.Text) = "NO" Or Not UCase(txtoverdraft.Text) = "YES" Then
    2.  
    3. 'if its not at the end of the file
    4. If (Not datCities.Recordset.EOF) And (Not datCities.Recordset.EOF) Then
    5.  
    6.         'Message box
    7.         MsgBox "Overdraft must be YES or NO"
    8.        
    9.         txtoverdraft.Text = ""
    10.        
    11.         'Doesn't save
    12.         Action = 0
    13.        
    14.         txtoverdraft.SetFocus
    15.  
    16. End If
    17. End If

    The value must be yes / YES / YEs etc.. or No / No/ nO etc.......

    How would I do this,

    Thanks joePC

  5. #5
    Frenzied Member
    Join Date
    May 2003
    Location
    So Cal
    Posts
    1,564
    Why dont you just convert it all to UCase and save yourself some headaches.

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