Is my math syntax wrong??

# Thread: Is my math syntax wrong??

1. Junior Member
Join Date
Dec 1969
Posts
12

## Is my math syntax wrong??

I&#039;m stuck on something and am hoping someone here can help. I have written a script that is supposed to assign a certain number of points based on a family&#039;s income and the number of people in their family, which are submitted via a form. There are several income brackets, each of which are pulled from a database table. (i.e. income bracket 1 includes IB1Low and IB1High). My problem is that the Points aren&#039;t being assigned. Here&#039;s how I&#039;m trying to calculate it:<BR><BR> &#039; assign to a bracket based on income<BR> &#039; number of points relates directly to number of people in family<BR> Dim IncomePts<BR><BR> &#039; first income bracket<BR> If income &#062;= IB1Low AND income &#060;= IB1High THEN<BR> IncomePts = num_family<BR> End If<BR> <BR> &#039; second income bracket<BR> If income &#062;= IB2Low AND income &#060;= IB2High THEN<BR> IncomePts = (num_family - 1)<BR> End If<BR><BR>I&#039;ve tried testing this in (what seems like) a gazillion different ways and no matter what I do, IncomePts comes back as NOTHING. (Not to be confused with zero!) Are there any blatant math mistakes here? Am I trying to do this the wrong way??

2. Senior Member
Join Date
Dec 1969
Posts
96,118

## And have you DEBUGGED?

Have you done<BR> Response.Write "income is " & income & "&#060;br/&#062;" _<BR> & "IB1Low is " & IB1Low & "&#060;br/&#062;" _<BR> & "IB1High is " & IB1High & "&#060;P&#062;"<BR>???<BR><BR>Have you checked the data types of all of those?<BR><BR> Response.Write "TypeName(income) is " & TypeName(income) & "&#060;br/&#062;" _<BR> & "TypeName(IB1Low) is " & TypeName(IB1Low) & "&#060;br/&#062;" _<BR> & "TypeName(IB1High) is " & TypeName(IB1High) & "&#060;P&#062;"<BR><BR>

3. Junior Member
Join Date
Dec 1969
Posts
12

## RE: And have you DEBUGGED?

I have done the first part - having it print the actual values of EVRYTHING for me - everything looks OK that way. BUT - I didn&#039;t know how to check the data type!! Thanks!!<BR><BR>It seems that both income and num_family are strings but they should actually be integers. How do I convert them? Would CInt(income) do this?

4. Junior Member
Join Date
Dec 1969
Posts
12

## RE: And have you DEBUGGED?

CInt(income) works. Thanks Bill. I knew I must be doing something dumb!!<BR><BR>Now my script works and I know more about debugging for my next error!!

5. Senior Member
Join Date
Dec 1969
Posts
96,118

## CDBL better than CINT...

CINT is limited to values from -32768 to +32767. So if some family had an income of \$33,000 you&#039;d get a big KABLOOEY if you use CINT.<BR><BR>You could use CLNG (which allows integers up to +/- two billion), but the safer thing to do is CDBL, which allows any legal numeric value.<BR><BR>

6. Junior Member
Join Date
Dec 1969
Posts
12

## RE: CDBL better than CINT...

Awesome. Thanks so much!

#### Posting Permissions

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