Results 1 to 5 of 5

Thread: [RESOLVED] Chr$

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2005
    Location
    Toronto, Canada
    Posts
    357

    Resolved [RESOLVED] Chr$

    Hello everyone,
    I was just going through this book I had about Internet Programming using Visual Basic 6.0.

    I came across this code:

    VB Code:
    1. dq = Chr$(34)
    2. sq = Chr$(39)

    dq and sq are variables

    The problem is that I don't understand what Chr$ does and I cannot find an explanation of it in the book. I looked up in the Object Browser of Visual Basic 6.0 and I get the following definiton:

    Chr$: Returns a string containing the character associated with the specific character code

    Format: Chr$(CharCode As Long)

    Now I understand that it returns a string containing the character associated... But all I am attaching are the digits 34 and 39. By these digits seem to be some sort of Character Codes... Could someone please explain what Character Codes are and what these two mean.

    Note: If someone can provide me with a list of all character codes and their explanations, I would really appreciated it.

    Thank you all in advance.

    Khanjan
    Hey... If you found this post helpful please rate it.

  2. #2
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Chr$

    The numbers that the Chr$ function accepts as a parameter are the numeric values of characters the way they are in the ASCII table.


    Has someone helped you? Then you can Rate their helpful post.

  3. #3
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Chr$

    The Long values represent the Ascii codes.

    Try this in a new project:
    VB Code:
    1. 'Place a ListBox on a Form.
    2. 'Will display All ASCII Characters
    3. Option Explicit
    4.  
    5. Private Sub Form_Load()
    6. Dim intIdx As Integer
    7.  
    8.     For intIdx = 0 To 255
    9.         List1.AddItem "Decimal: " & intIdx & " = Char: " & Chr$(intIdx)
    10.     Next
    11.  
    12. End Sub

  4. #4
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: Chr$

    The character codes are the ASCII values of the characters. 34 is the double-quote (") and 39 is the single-quote('). You can find a chart of them here. (Use the Dec values [the first column].)
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2005
    Location
    Toronto, Canada
    Posts
    357

    Re: Chr$

    Oh thanx a lot guys...
    Basically what my program is trying to do is get the html tags. And since the location in the tags can be in double quoted (") or single quoted ('), the variables are being assigned the ASCII value of these... basically trying to find the link part of the html tag. Thanx a lot guys, I appreciate your help.

    Khanjan
    Hey... If you found this post helpful please rate it.

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