Batchman Posted October 1, 2003 Posted October 1, 2003 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 Quote
AlexCode Posted October 1, 2003 Posted October 1, 2003 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... Quote Software bugs are impossible to detect by anybody except the end user.
Batchman Posted October 1, 2003 Author Posted October 1, 2003 I had to use the and signs with some SQL Script, thought that's how you represented all code to fit in windowed area. My mistake. Quote
Administrators PlausiblyDamp Posted October 2, 2003 Administrators Posted October 2, 2003 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. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
AlexCode Posted October 2, 2003 Posted October 2, 2003 Worked ? Quote Software bugs are impossible to detect by anybody except the end user.
Batchman Posted October 2, 2003 Author Posted October 2, 2003 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! Quote
AlexCode Posted October 2, 2003 Posted October 2, 2003 That's why we're here for ... :D Quote Software bugs are impossible to detect by anybody except the end user.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.