Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

 

 

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

  • *Experts*
Posted

Replace this:

(radMensShoes.Checked = False Or radWomensShoes.Checked = False)

with

(radMensShoes.Checked = False AndAlso radWomensShoes.Checked = False)

Otherwise it will fail unless BOTH checkboxes are checked.

 

Also, you should use OrElse instead of Or in these cases, as it is more efficient.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...