Results 1 to 11 of 11

Thread: Chr and ChrB.. Why doesn't work????

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Italy
    Posts
    90

    Unhappy

    Hi everyone,
    I have tried a sample code in a form with 2 buttons and 3 textfields:

    Private Sub Command1_Click()
    Text3.Text = Asc(Text1.Text)
    End Sub

    Private Sub Command2_Click()
    If Text3.Text > 31 Then
    Text2.Text = Chr(Text3.Text)
    Else
    Text2.Text = ChrB(Text3.Text)
    End If
    End Sub

    This should work, but when i put in Text3 a value under 31, in Text2 nothing appears. Can you help me please?

  2. #2
    Guest
    not surprising really, Ascii char 31 is not supported by windows, in other words some fonts will show nothing.

    install the MSDN library if you havent already and use it: go to the index and type "Ascii Character Codes", and you'll get a map of them.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Italy
    Posts
    90

    Bad thing!

    Ahi ahi... this is a bad thing... any idea on how to solve this problem?

  4. #4
    Guest
    It's best to stay away from character's 0-31 and 127-159.

  5. #5
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    It's in the VB5 help file (at least). Also, try Character Map for all the characters 32->256.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  6. #6
    Guest
    Parksie: You are forgetting characters 127-159 are not supported by Windows

    Override:
    Code:
    If Not (Asc(Text1) > 32 And Asc(Text1) < 127) Or Asc(Text1) > 159 Then
        'Key is invalid
    End If

  7. #7
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Strange. Then how come in Character Map, when selecting Times New Roman, I have a total of 224 characters displayed?
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  8. #8
    Guest
    Yes, actually you're right, but 127-159, for the most part, are only supported with TTF. If you try it with a Non-TTF (which includes the standard MS Sans Serif) then chances are it won't work.

  9. #9
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Hmm. It's got characters for those as well! I tried MS Sans Serif, MS Serif, Terminal, Fixedsys and some others and they all had those characters supported. Although most of them missed 127->159 out. The chars from 160->255 seemed to be stuff like é and ô.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Italy
    Posts
    90

    Talking

    That's strange, i have tried chars beetween 127 - 159 and
    actually they don't give me any kind of problem. They work
    well, i am using Terminal Font.
    Just another question:
    I have to send to a multiline textfield a simulation of an
    Enter keystroke.
    If i want to add a simple character then i do
    Text1.Text + "a"
    but how to send a enter keystroke?
    Text1.Text + ENTER
    Does not work! Eheh! ;-)))

  11. #11
    Guest
    For ENTER use:

    Code:
    'Either this
    Text1.Text = Text1.Text & vbNewLine
    'Or this
    Text1.Text = Text1.Text & vbCrLf

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