Meaning of Code

k209310

Active Member
Joined
Aug 12, 2002
Messages
382
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
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
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).
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,213,528
Messages
6,114,154
Members
448,553
Latest member
slaytonpa

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top