Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 134
Default formatting text in TextBox in UserForm

I'd like users to be able to enter single digit numbers into a TextBox but have the code format this as a four-character text string, e.g., "0000". Is this possible?

Thanks.


Kevin
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default formatting text in TextBox in UserForm

Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If IsNumeric(TextBox1.Value) Then
If Len(Trim(TextBox1.Value)) = 1 Then
TextBox1.Value = Format(CLng(TextBox1.Value), "0000")
Else
MsgBox "Single Digit Numbers only"
TextBox1.Value = ""
Cancel = True
End If
Else
MsgBox "Entry must be numeric and single digit"
TextBox1.Value = ""
Cancel = True
End If
End Sub

--
Regards,
Tom Ogilvy

"Kevin" wrote in message
...
I'd like users to be able to enter single digit numbers into a TextBox but

have the code format this as a four-character text string, e.g., "0000". Is
this possible?

Thanks.


Kevin



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 134
Default formatting text in TextBox in UserForm

Thanks Tom. It works like a charm.

Kevin
-----Original Message-----
Private Sub TextBox1_Exit(ByVal Cancel As

MSForms.ReturnBoolean)
If IsNumeric(TextBox1.Value) Then
If Len(Trim(TextBox1.Value)) = 1 Then
TextBox1.Value = Format(CLng

(TextBox1.Value), "0000")
Else
MsgBox "Single Digit Numbers only"
TextBox1.Value = ""
Cancel = True
End If
Else
MsgBox "Entry must be numeric and single digit"
TextBox1.Value = ""
Cancel = True
End If
End Sub

--
Regards,
Tom Ogilvy

"Kevin" wrote in

message
...
I'd like users to be able to enter single digit numbers

into a TextBox but
have the code format this as a four-character text

string, e.g., "0000". Is
this possible?

Thanks.


Kevin



.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
userform textbox Phil Excel Worksheet Functions 5 January 16th 05 06:59 PM
Calculating a textbox on a userform Patrick Simonds Excel Programming 3 November 7th 03 06:07 AM
Retaining text formatting in TextBox Tom Ogilvy Excel Programming 0 September 9th 03 08:05 PM
UserForm TextBox to ActiveSheet TextBox over 256 characters Dan E[_2_] Excel Programming 1 July 28th 03 07:36 PM
Populating Textbox in UserForm Derek[_2_] Excel Programming 3 July 10th 03 10:41 PM


All times are GMT +1. The time now is 06:33 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"