Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > how to find if a variable is an INT or a CHAR

Reply
Thread Tools

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

 
 
mark
Guest
Posts: n/a
 
      05-26-2005
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


 
Reply With Quote
 
 
 
 
Mark Rae
Guest
Posts: n/a
 
      05-26-2005
"mark" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

> can this be done easily ?


Since you're using VB.NET, why not just use IsNumeric(...)?


 
Reply With Quote
 
 
 
 
=?Utf-8?B?RWx0b24gVw==?=
Guest
Posts: n/a
 
      05-26-2005
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
http://www.velocityreviews.com/forums/(E-Mail Removed)


"mark" wrote:

> 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
>
>
>

 
Reply With Quote
 
mark
Guest
Posts: n/a
 
      05-26-2005

"Mark Rae" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "mark" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
> > can this be done easily ?

>
> Since you're using VB.NET, why not just use IsNumeric(...)?
>

thats exactly what i was looking for nice n easy too! works a treat

mark


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
int urldecode(char *src, char *last, char *dest) gert C Programming 20 02-16-2007 11:28 PM
(const char *cp) and (char *p) are consistent type, (const char **cpp) and (char **pp) are not consistent lovecreatesbeauty C Programming 1 05-09-2006 08:01 AM
int main(int argc, char *argv[] ) vs int main(int argc, char **argv ) Hal Styli C Programming 14 01-20-2004 10:00 PM
newbie: char* int and char *int trey C Programming 7 09-10-2003 03:24 AM
dirty stuff: f(int,int) cast to f(struct{int,int}) Schnoffos C Programming 2 06-27-2003 03:13 AM



Advertisments