Data Types ?????

1. Daza Guest

## Data Types ?????

Hello all<BR>I am reading from a QueryString some numeric(or so i thought) values that are seperated by commas . I have split these into an array and am trying to add the values together BUT they are being read as strings because all that happens is they are joined together.<BR>Is there something i need to do to convert these from strings into numbers ???<BR><BR><BR>Can ya help please<BR><BR>Daza<BR>PS Heres some code<BR>########################################## ##<BR>ft = Trim(Request.QueryString("total"))<BR><BR>sec = Split(ft,",",-1,1)<BR><BR>Dim cost<BR>y = LBound(sec)<BR>while y &#060;= UBound(sec)<BR>cost = cost & sec(y)<BR>y = y + 1<BR>wend<BR><BR>#############################

2. Daza Guest

## OOOPPPPS made a mistake in my post

cost = cost & sec(y)<BR>SHOULD READ<BR>cost = cost + sec(y)

3. Senior Member
Join Date
Dec 1969
Posts
989

## RE: OOOPPPPS made a mistake in my post

you can use &#039;CInt(variable_name)&#039; to convert them to integers first

4. bob digital Guest

## try this

hey daza,<BR><BR>before you step into the while loop, set cost = 0 (just good coding practice).. then, cast sec(y) to an integer (or whatever type of numeric value you want) when you add it to cost for each iteration in the loop - it should read:<BR><BR>cost = cost + Cint(sec(y))<BR><BR>hope that helps!

5. Daza Guest

## RE: try this

I tried that declared cost = 0 and got...<BR><BR><BR>8.81 this is sec<BR>11.75 and this<BR>52.88 and this<BR><BR>Microsoft VBScript runtime error &#039;800a000d&#039; <BR><BR>Type mismatch: &#039;sec(...)&#039; <BR><BR>And if i do the CInt(sec(y)) I get<BR><BR>Microsoft VBScript runtime error &#039;800a000d&#039; <BR><BR>Type mismatch: &#039;CInt&#039; <BR><BR>#################<BR><BR>Help<BR><BR>Daza< 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
•