Format a text box in user form as number but accept backspac

SOUTHY63

New Member
Joined
Feb 1, 2005
Messages
16
Hi,

I am trying to set up a user form with values entered into a text box then another textbox with the adition of two of them. When I hit the back space key in textbox 1 it errors as a type mismatch. How can I allow the backspace to be entered.

the code is as follows

If TextBox1 > 0 Then
If TextBox2 = "" Then
TextBox2.Value = 0
Else
End If
Dim WhitePaper As Integer
Dim ColourPaper As Integer
WhitePaper = TextBox1.Value (ERRORS HERE WITH BAKCSPACE)
ColourPaper = TextBox2.Value
TextBox3.Value = WhitePaper + ColourPaper
Else
End If
End Sub
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Re: Format a text box in user form as number but accept back

I wouldnt think a backpace would cause a problem but a non numeric will such as a space character. Try Trim... or the Clean worksheet function if its in between numbers (ie not first or last character). Youve only posted some of your code and you havent indicated if this is an event procedure.

WhitePaper = Trim(TextBox1.Value)
 
Upvote 0

Forum statistics

Threads
1,203,115
Messages
6,053,598
Members
444,674
Latest member
DWriter9

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