Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I want to make sure all fields have a value before the submit button is enabled. The following code works, except that once cmbDv is filled in, it enables the button without waiting for cmbAc to be filled in. It's got to be something simple. Here is my code:

 

Dim check As Integer

check = 0

If cmbReq.Text = "" Or cmbEq.Text = "" Or cmbBl.Text = "" & _

Or cmbFl.Text = "" Or cmbRm.Text = "" Or txtLoc.Text = "" & _

Or cmbPt.Text = "" Or txtDesc.Text = "" Or cmbDp.Text = "" & _

Or cmbDv.Text = "" Or cmbAc.Text = "" Then

check = 1

Else

check = 0

End If

 

If check = 0 Then

btnSubmit.Enabled = True

End If

 

I call this function from my timer so it is always looping.

Thanks in advance

Posted

Firrst of all... don't use the 0 (zero) as the true value! It's not that the code will work better but it's a standard that the 1 is the true value... It helps to understand the code better...

 

I don't have time to test the code but ... why do you put those '&' at the end of each line break?? You only need the underscore...

Software bugs are impossible to detect by anybody except the end user.
  • Administrators
Posted

Try re-writing the code without all the '&' symbols - that could be causing problems.

Also rather than using 1 and 0 (or -1 or any other number) to represent a true / false scenario declare Check as a Boolean value - it can then be set to either true or false! Easier to read, more obvious than trying to interpret the 'secret' meaning of a number.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted
Actually, I edited the code to add to the forum and added the line breaks. The code in my program is one continuous line (the post used word wrap) up to the 'then statement'. I am fairly new at this, the true-false would make more sense, I wasn't aware that it was an option. Thanks for all your input!

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...