#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    21
    Rep Power
    0

    Trying to find the value of character


    I've been pulling some data from the database, and it's returning a string of 10 characters. (I can't modify the database, so I have to do this programically) If there is no value in the string, it still returns a length 10 string with 10 invisible characters (The data type from the database is Char, and I've tried changing the values to something else, it doesn't work).

    I want to try to modify this string as they're coming in. If they contain no numbers, I want to trim the string down to nothing(I've tried .trim(), it doesn't work).

    So far, I can't tell what is IN the string at all. It doesn't seem to think it's a Null value, white space, punctuation etc. it seems to think EVERY character is a number even when there is definately is no numbers.

    I have tried this code:
    Code:
    If charAr(1).IsPunctuation(charAr(0)) = True Then Response.Write("We have a Punctuation!<BR>")
    If charAr(1).IsWhiteSpace(charAr(0)) = True Then Response.Write("We have a WhiteSpace!<BR>")
    If charAr(1).IsSeparator(charAr(0)) = True Then Response.Write("We have a Separator!<BR>")
    If charAr(1).IsSurrogate(charAr(0)) = True Then Response.Write("We have a Surrogate!<BR>")
    If charAr(1).IsSymbol(charAr(0)) = True Then Response.Write("We have a Symbol!<BR>")
    If charAr(1).IsNumber(charAr(0)) = True Then Response.Write("We have a Number!<BR>")
    If charAr(1).IsLetter(charAr(0)) = True Then Response.Write("We have a Letter!<BR>")
    And it Always returns "We have a number!" no matter what the content of the string may be (including letters).

    I have also tried
    Code:
    If charAr(1).IsNumber(charAr(0)) = True Then
                temp = charAr(1).GetNumericValue(charAr(0))
                If temp >= 0 And temp <= 9 Then Response.Write("We have a Number!<BR>")
            End If
    And it still ALWAYS thinks it's a number, even when there is no number in there.

    is there any other way to test for what the character IS in this string? Or is there a good way to SHOW me what's in the string so I can create an if statement to ignore those characters?

    Thank you, anyone who has suggestions
    Last edited by trueneutral; September 26th, 2003 at 02:01 PM.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    109
    Rep Power
    12
    Iíve noticed similar problems when converting from a fixed length string to a .NET string object. Regardless of whether a string is fixed or variable length it should be null terminated (in fact Iím not too sure where .NET is running into problems). To check if the string is empty you should check to see if the first character is the null character (Ď\0í). Iíve also noticed string comparison problems with incorrectly converted strings.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    21
    Rep Power
    0
    Hello Nem

    Thanks for the reply. I actually got this sorted out for the most part

    I should have been using Char instead of charAr(1) like this:

    if char.IsPunctuation(charAr(0)) = True Then Response.Write("We have a Punctuation!<BR>")

    Once I started doing that, everything started working again. But thanks for the input

IMN logo majestic logo threadwatch logo seochat tools logo