Results 1 to 6 of 6

Meaning of Code

This is a discussion on Meaning of Code within the Excel Questions forums, part of the Question Forums category; I have been using this code from a previous post. The code prevents any characters other than text from being ...

  1. #1
    Board Regular
    Join Date
    Aug 2002
    Location
    Newcastle
    Posts
    382

    Default

    I have been using this code from a previous post. The code prevents any characters other than text from being entered in to a text box. (Using the key press)

    I was wondering out of general interest if anybody had any idea of how it works?

    Select Case KeyAscii
    Case Is < 46
    KeyAscii = 8
    Case Is > 57
    KeyAscii = 8
    Case 47
    KeyAscii = 8


  2. #2
    MrExcel MVP
    Moderator
    Andrew Poulsom's Avatar
    Join Date
    Jul 2002
    Posts
    64,611

    Default

    KeyAscii is a variable containing the Ascii character value. Characters 48 to 57 are the numbers 0 - 9. Character 47 is /. Character 8 is Backspace. So if it's not a number it is deleted (by Backspace).

  3. #3
    Board Regular
    Join Date
    Aug 2002
    Location
    Newcastle
    Posts
    382

    Default

    Thanks for that.

    So presumably I could set the code to allow certain signs, such as £, to be entered in string postion 0. Ill have a look for the ASCII numbers.

    Thanks again

    Chris

  4. #4
    MrExcel MVP
    Moderator
    Andrew Poulsom's Avatar
    Join Date
    Jul 2002
    Posts
    64,611

    Default

    It's 163.

  5. #5
    Board Regular XL-Dennis's Avatar
    Join Date
    Jul 2002
    Location
    ÷stersund, Sweden
    Posts
    1,922

    Default

    Hi,

    Following procedure will give You a list of chars in the active sheet and in the A-column:

    Sub Chr_Number()
    Dim i As Long

    For i = 1 To 255
    Cells(i, 1).Value = Chr(i)
    Next i

    End Sub

    Kind regards,
    Dennis

  6. #6
    Board Regular
    Join Date
    Jun 2002
    Location
    Perth, Australia
    Posts
    1,416

    Default

    Chris,

    In cell A1 put "=CHAR(ROW())" (without the apostrophes) and then drag down to cell A256. You will need to use a font like Arial, Times New Roman, Courier, Verdana etc.

    In B1, C1 and D1 put the above formula and drag down. Format columns B, C and D with Windings, Webdings and Monotype Sorts respectively. You will get some interesting characters.

    Regards

    Mike

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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


DMCA.com