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

Discussion in 'ASP .Net' started by mark, May 26, 2005.

  1. mark

    mark Guest

    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
     
    mark, May 26, 2005
    #1
    1. Advertising

  2. mark

    Mark Rae Guest

    "mark" <> wrote in message
    news:...

    > can this be done easily ?


    Since you're using VB.NET, why not just use IsNumeric(...)?
     
    Mark Rae, May 26, 2005
    #2
    1. Advertising

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



    "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
    >
    >
    >
     
    =?Utf-8?B?RWx0b24gVw==?=, May 26, 2005
    #3
  4. mark

    mark Guest

    "Mark Rae" <> wrote in message
    news:...
    > "mark" <> wrote in message
    > news:...
    >
    > > 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
     
    mark, May 26, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Schnoffos
    Replies:
    2
    Views:
    1,221
    Martien Verbruggen
    Jun 27, 2003
  2. trey

    newbie: char* int and char *int

    trey, Sep 10, 2003, in forum: C Programming
    Replies:
    7
    Views:
    405
    Irrwahn Grausewitz
    Sep 10, 2003
  3. Hal Styli
    Replies:
    14
    Views:
    1,648
    Old Wolf
    Jan 20, 2004
  4. lovecreatesbeauty
    Replies:
    1
    Views:
    1,061
    Ian Collins
    May 9, 2006
  5. gert
    Replies:
    20
    Views:
    1,170
Loading...

Share This Page