Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pattern checker

Status
Not open for further replies.

neofactor

Technical User
Jul 30, 2000
194
US
We have a form of 6 variables... each with a number.

If the user enters a value of a Zero.... then none of the other feilds should contain values..... how do I check to see if they messed up?


Say
Field 1 = 1123
Field 2 = 2234
Field 3 = 0
Field 4 = 1122
Field 5 = 0
Field 6 = 0


How do I report an error that they have a null in field 3 and had valid data after.......

It is ok if the have trailing 0's as long as a following field does not have a value.. just zeros.

Once a zero is found in the list... all other fields should be zero only.

Does this make sense?

Any ideas?
 
Here is one way to do it.

Note this is for theory only, the syntax is VERY bad. It is a mix of CF and VB.

-----------------------------------------------

bZeroFound = FALSE
s = ""

If field1 IS 0
bZeroFound = TRUE
End If
If field2 IS 0
If bZeroFound = TRUE
s = "Field2"
Else
bZeroFound = TRUE
End If
End If
If field3 IS 0
If bZeroFound = TRUE
s = "Field3"
Else
bZeroFound = TRUE
End If
End If
If field4 IS 0
If bZeroFound = TRUE
s = "Field4"
Else
bZeroFound = TRUE
End If
End If
........

If bZeroFound = TRUE Then MsgBox("#s# is a bunch of @%$#!!")

-----------------------------------------------

Kris
 
Sort of...


But what if someone enters a Valid list like:

field 1 = 1111
Field 2 = 2222
Field 3 = 0
Field 4 = 0
Field 5 = 0


See how the Zeros are continuous as aposed to:

field 1 = 1111
Field 2 = 2222
Field 3 = 0
Field 4 = 4444
Field 5 = 0

This would be invalid...

Checking for a zero is not enough.. but it only has zeros following is the trick

Did I misread your solution?
 
Can you check on entering the data? If so, check when entering into 2 that 1 > 0, entering 3 if 2 > 0 etc.
otherwise you have to simulate that after input and set a flag to indicate valid or invalid.
Code:
b_valid = false;
if (2 > 0 && 1 > 0) b_valid = true;
if (3 > 0 && 2 > 0) b_valid = true;
etc
if (b_valid) submit()
else msg

Erwin Oosterhoorn
Analyst Programmer,
Roller hockey'er, biker,
ice hockey player/fan.
 
A better way may be:

Put the values in a list....

111,222,333,0,555
Find the first zero...
if the sum of the rest of the values after that zero is qual to a toal of zero.. it is ok... else... invalid.

I'll play with this and get back with ya.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top