Results 1 to 4 of 4

Thread: Help?! validating blank fields

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2003
    Posts
    1

    Help?! validating blank fields

    Hello All
    I am getting used to VB.net - I remember (I think) in VB 6 that if a txtBox.text = "" then it was considered a blank field. I can't get this code to work - I keep getting the message box (error) but I want the ELSE statement to work if it is ( the fields) filled in.

    Code
    Code:
    Private Sub btnOrder_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOrder.Click
            If txtName.Text = "" Or cmbBrand.Text = "" Or cmbStyle.Text = "" Or cmbSize.Text = "" _
            Or (radMensShoes.Checked = False Or radWomensShoes.Checked = False) Then
    
                MsgBox("Please fill in all fields" & Environment.NewLine & "you may leave width unchecked")
            Else
                txtBox1.Text = ("Thank You " & txtName.Text & Environment.NewLine & "Men's Shoes:" & radMensShoes.Checked & _
               Environment.NewLine & "Women's Shoes:" & radWomensShoes.Checked & Environment.NewLine & "Brand: " & cmbBrand.Text & Environment.NewLine & _
               "Style: " & cmbStyle.Text & Environment.NewLine & "Size: " & cmbSize.Text & Environment.NewLine & "Width:" & chbWidth.Checked)
    
    
            End If
    
    
    
        End Sub
    Thanks
    Rob

  2. #2
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429
    Rob,

    You find you get a result if you post your VB.Net question in the VB.Net Forum. This Forum is for VB6

    You can find the VB.Net Forum here.



    Bruce.

  3. #3
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Dublin (Ireland)
    Posts
    304
    try this:

    If trim(TextBox1.text).length = 0 then

    ' field is blank
    else

    'field contains data

    end if

  4. #4
    Addicted Member The Phoenix's Avatar
    Join Date
    Aug 2003
    Location
    With my wife
    Posts
    142
    Do you mean that you get an error, or does it show the message box that you have there in your code? If you are getting the message box from your code, I would try taking the parentheses from around the "radMensShoes.Checked = False Or radWomensShoes.Checked = False". I don't really see why it would change anything, but it's the only thing that comes to mind.
    Take my love
    Take my land
    Take me where I cannot stand
    I don't care, I'm still free
    You can't take the sky from me...

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