how to find if a variable is an INT or a CHAR

M

mark

i create a table on the fly using sql,

using syntax like :-

commitmentsstring = commitmentsstring & "<tr><td><FONT face=""Arial""
size=""2"">" & ds.Tables(0).Rows(counter)(2) & "</FONT></td>" & "<td><FONT
face=""Arial"" size=""2"">" & ds.Tables(0).Rows(counter)(3) & "</FONT></td>"
& "<td><FONT face=""Arial"" size=""2"">" & ds.Tables(0).Rows(counter)(4) &
"</FONT></td>" & "<td><FONT face=""Arial"" size=""2"">" &
ds.Tables(0).Rows(counter)(5) & "</FONT></td>" & "<td><FONT face=""Arial""
size=""2"">" & ds.Tables(0).Rows(counter)(6) & "</FONT></td>" & "<td><FONT
face=""Arial"" size=""2"">" & ds.Tables(0).Rows(counter)(7) &
"</FONT></td></tr>"

with a for while loop,

i do additions for particular columns like this :-

If ds.Tables(0).Rows(counter)(2) = "1" And ds.Tables(0).Rows(counter)(6) >
"" Then
totalbalance1 = totalbalance1 + Int(ds.Tables(0).Rows(counter)(6))
End If

i need to check to see if ds.Tables(0).Rows(counter)(6) is a INT or a CHAR
eg

If ds.Tables(0).Rows(counter)(2) = "1" And ds.Tables(0).Rows(counter)(6) >
"" And ds.Tables(0).Rows(counter)(6) "isn't a char" Then
totalbalance1 = totalbalance1 + Int(ds.Tables(0).Rows(counter)(6))

can this be done easily ?

cheers

mark
 
G

Guest

Hi Mark,

You can use TypeOf...Is operator to determine object type, e.g.

If TypeOf obj Is Integer Then
intValue = Convert.ToInt32(obj)
End If

HTH

Elton Wang
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top