Results 1 to 3 of 3

Thread: [RESOLVED] Ascii Function

  1. #1

    Thread Starter
    Fanatic Member Wen Lie's Avatar
    Join Date
    Jul 1999
    Location
    Singapore
    Posts
    524

    Resolved [RESOLVED] Ascii Function

    Hi....

    I'm confuse about the ascii function in C#, coz I'm a newbie here.
    I'm using VB6 before. I don't know what syntax should I use in C#.

    At VB6, I use as below :

    Code:
    Dim AA as string
    Dim BB
    Dim i
    
    AA = "Hello"
    for i = 1 to len(AA)
         BB = mid(trim(AA), i, 1)
         msgbox Asc(BB)
    next i
    how should I write those code in C# ?
    Thanks...

    ** Willy **
    Last edited by Wen Lie; May 4th, 2007 at 12:07 AM. Reason: problem solved
    Regards,
    [-w-]

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Ascii Function

    You could write fairly similar code but you wouldn't want to. You get the length of a string from its Length property, you get part of a string using its Substring method, and you get the numerical value of a character using the Comnvert.ToInt32 method. That can all be written much more succinctly in C# though:
    vb Code:
    1. string myString = "Hello";
    2.  
    3. foreach (char ch in myString)
    4. {
    5.     MessageBox.Show(Convert.ToInt32(ch).ToString());
    6. }
    Note that the VB.NET code would be similar, although you could also write VB.NET code that more closely resembled the original.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Fanatic Member Wen Lie's Avatar
    Join Date
    Jul 1999
    Location
    Singapore
    Posts
    524

    Smile Re: Ascii Function


    thanks...
    i've tried and work...
    many thanks.

    ** willy **
    Regards,
    [-w-]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width