Create an input mask on a text box

svmac

Board Regular
Joined
Feb 16, 2002
Messages
182
I have a userform, containing various items that all do exactly what I need - except for one particular textbox.

The user enters an interest rate in this box, but I don't want it to create a problem if they enter 4.99 as a number, rather than 4.99%. Is there a way to create an input mask or something similar that automaticall appends the % to the end of the number as it is typed?
Thanks in advance,
Stuart Macdonald
_________________
Business Analyst
Australian Central Credit Union Ltd
http://www.accu.com.au
This message was edited by svmac on 2002-08-29 17:15
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Hi
It would somewhat more complicated to append the % as the text is typed. Using the BeforeUpdate event should do well enough.
<pre>
Private Sub TextBox1_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
If Not Right(TextBox1, 1) = "%" Then TextBox1 = TextBox1 & "%"
End Sub

</pre>
Tom
 
Upvote 0
Thnx for the reply Tom.

I managed to work out another method that will suit me.

I placed % as the value of the RateTextBox properties, and then added the following to the UserForm_Initialize() sub:

Private Sub UserForm_Initialize()
RateTextBox.SetFocus
RateTextBox.CurX = 0
End Sub

This places the cursor at the start of the text box, in front of the % sign. Should sort me out - if it doesn't, I will give your method a go.

Many thanks
Stuart Macdonald
 
Upvote 0

Forum statistics

Threads
1,217,317
Messages
6,135,841
Members
449,965
Latest member
Ckl43

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