Using ascii code in Excel UserForm Textbox

Oseitutuakrasi

New Member
Joined
Jun 7, 2023
Messages
38
Office Version
  1. 365
Platform
  1. Windows
Dear All,
Admittedly, I'm not sure if this is possible. I can directly enter an ascii character (such as a % sign) into a Textbox by using the Numlock keypads with the ALT key.
That is fine. But I want this to happen automatically when I activate the form. This is what I have done:
UserForm1.Activate()
Sendkeys "{Numlock}", True ' To activate pressing the NumLock key
Sendkeys ("%8373") ' I am told that the % simulates the ALT key. So, I am pressing the ALT key as I enter 8373
End Sub

I was hoping that the above code will simulate pressing the NumLock key, then press (and hold down) the ALT as I enter the code 8373
However, when the form opens the text box contains only 373. The 8 is missing and the character I was expecting does not appear. I have the feeling that the ALT key does not stay down, but I could be wrong. Any help please?

Regards,
Sam
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
You can use ChrW function:
VBA Code:
TextBox1.Text = ChrW(8373)
 
Upvote 0
You're welcome, glad to help & thanks for the feedback.:)
 
Upvote 0
@Oseitutuakrasi
Just additional info, if you want to know the code number of a unicode character, you can put the character in a cell and then use UNICODE function, like this:
Book1
AB
19660
29650
39670
48373
Sheet5
Cell Formulas
RangeFormula
B1:B4B1=UNICODE(A1)
 
Upvote 0

Forum statistics

Threads
1,224,819
Messages
6,181,153
Members
453,021
Latest member
Justyna P

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