Getting creazi with set if IF's testing for =

# Thread: Getting creazi with set if IF's testing for =

1. Senior Member
Join Date
Dec 1969
Posts
334

## Getting creazi with set if IF's testing for =

I need to check whether a set of strings contain numbers (Is Numenric) and if numeric whether they are &#060;&#062; 0 <BR><BR>I found the following problems: <BR><BR>1) if I use the sentence If IsNumeric(MyString1) = true I cannot concatenate the sentence with other IsNumeric(MyString2), IsNumewric(MyStringn) because it looks like the "= true" is expecting a "then" immediately after.<BR><BR>2) I cannot use the following combinations of comparisons :<BR>If TEST1 = 1 and ( MyString1 &#060;&#062;0 or MyString2 &#060;&#062;0 or . . .)<BR> then. . . <BR><BR>In conclusion: if I have 4 strings (a, b, c, and d) and I need to check whether they are ALL numeric, in which case I need to check whether at least one of them is &#060;&#062; 0 <BR>if the condition is satisfied I pick up the 4 fields and carry on with processing, otherwise I move to the next record.<BR><BR>Can you help setting up the easiest way to accomplish this task.<BR><BR>Thanks and regards,<BR><BR> Guglielmo

2. Senior Member
Join Date
Dec 1969
Posts
733

## RE: Getting creazi with set if IF's testing f

if isNumeric(a) and isNumeric(b) and isNumeric(c) and isNumeric(d) then<BR><BR> if (a+b+c+d) &#062; 0 then<BR> &#039; at least one of the values is &#062; 0<BR> end if<BR><BR>end if

3. Senior Member
Join Date
Dec 1969
Posts
334

## RE: Getting creazi with set if IF's testing f

. . . going to test.<BR><BR>Thanks a lot<BR><BR> gug

4. Senior Member
Join Date
Dec 1969
Posts
334

## RE: Getting creazi with set if IF's testing f

Now the problem is moved to another area: floating versus integer. . .<BR><BR>I have an error message because I am tryuing to add up 150 + 29.4 + 179.4<BR><BR>To me they are all numeric and non zero. why the system is giving the following error<BR><BR><BR>Microsoft VBScript runtime error &#039;800a000d&#039; <BR><BR>Type mismatch: &#039;[string: "15029.4179.4"]&#039; <BR><BR>/Easijet/Easijet_Process_TEST/User_csv_files/HHValidation.asp, line 571 <BR><BR><BR>Do I need to define somehow the 4 fields one checked out that thay are all numeric. <BR>By the way I am reading a text file (csv) and I shall create a SQL table loading only records with those 4 fields numeric, one of them at least shall be non zero, plus other conditions on other fields which do not seem to be a problem.<BR><BR>Thanks<BR><BR> Gug

5. Senior Member
Join Date
Dec 1969
Posts
733

it looks like you are trying to combine the values as strings rather than summing them. Are you using & or +?

6. Senior Member
Join Date
Dec 1969
Posts
334

I am using + hereunder is the code <BR><BR><BR>Function funAMOUNTS(WNETR2, WVATNR2, WRECV2, WBANKCHG2)<BR> If IsNumeric(WNETR2) and IsNumeric(WVATNR2) and IsNumeric(WRECV2) and IsNumeric(WBANKCHG2) Then<BR> funAMOUNTS = "Y" <BR> Else<BR> funAMOUNTS = "N"<BR> End If<BR> <BR> If funAMOUNTS = "Y" and WNETR2 + WVATNR2 + WRECV2 + WBANKCHG2 &#060;&#062; 0 then<BR> funAMOUNTS = "Y" <BR> else <BR> funAMOUNTS = "N"<BR> End If <BR>End Function <BR>

7. Senior Member
Join Date
Dec 1969
Posts
733

I just created the following and it worked fine:<BR><BR>[code language="VBScript"]&#060;% <BR>a = 150<BR>b = 45.6<BR>c = 37.1<BR>d = 9<BR><BR>Function funAMOUNTS(WNETR2, WVATNR2, WRECV2, WBANKCHG2) <BR> If IsNumeric(WNETR2) and IsNumeric(WVATNR2) and IsNumeric(WRECV2) and IsNumeric(WBANKCHG2) Then <BR> funAMOUNTS = "Y" <BR> Else <BR> funAMOUNTS = "N" <BR> End If <BR> <BR> If funAMOUNTS = "Y" and WNETR2 + WVATNR2 + WRECV2 + WBANKCHG2 &#060;&#062; 0 then <BR> funAMOUNTS = "Y" <BR> else <BR> funAMOUNTS = "N" <BR> End If <BR>End Function<BR>%&#062; <BR>&#060;HTML&#062; <BR>&#060;BODY&#062; <BR>&#060;p&#062;&#060;%=funAmounts(a,b,c,d)%&#062 ;&#060;/p&#062;<BR>&#060;/BODY&#062; <BR>&#060;/HTML&#062;<BR>[/code]<BR><BR>can yu show me the code around line 571?

8. Senior Member
Join Date
Dec 1969
Posts
334

## RE: Your problem is elsewhere

line 571 is right the following one<BR><BR>If funAMOUNTS = "Y" and WNETR2 + WVATNR2 + WRECV2 + WBANKCHG2 &#060;&#062; 0 then <BR><BR>I am going to check whether it is possible that I have some screw before passing fields to Funtion.<BR><BR>Thanks for the moment.<BR><BR>Gug<BR>Regardsarrew g<BR>I undertstand na dI

9. Senior Member
Join Date
Dec 1969
Posts
334

## RE: May be but it is very strange . . . . .

I do have several records in input <BR><BR>the first one has only integer amounts and does not give any error. The second one has one amount integer and two amounts with decimals and it gives the error . . .<BR><BR>Does it tell anything to you ?<BR><BR>Gug<BR>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•