Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 104
Default locking textbox?!

Hello All,

i have a textbox that has to have a number entered into it that is 0
& <10.
i can quite easily write a longish routine in the textbox_change event
procedure using isnumeric & len() to test each new character that the
user inputs into the textbox

; but is there a quicker solution?


Thanks in advance
Jason
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default locking textbox?!

Jason,

1) Can you wait until the user clicks a commandbutton (OK/Done button) and
then validate the textbox.

2) Can you use the Textbox_Exit event?(see code below) I don't know if your
design fits this usage (requires the user to hit enter or tab to another
control).

Troy


Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim sValue As String
Dim dblValue As Double

sValue = Me.TextBox1.Value
If IsNumeric(sValue) Then
dblValue = CDbl(sValue)
If dblValue <= 0 Or dblValue = 10 Then
MsgBox "Please enter a number between 0 and 10"
Cancel = True
End If
Else
MsgBox "Please enter a numeric value"
Cancel = True
End If
End Sub


"jason" wrote in message
om...
Hello All,

i have a textbox that has to have a number entered into it that is 0
& <10.
i can quite easily write a longish routine in the textbox_change event
procedure using isnumeric & len() to test each new character that the
user inputs into the textbox

; but is there a quicker solution?


Thanks in advance
Jason



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
Calculate Textbox value based on another textbox value.doc Tdungate Excel Discussion (Misc queries) 1 February 12th 09 07:11 PM
Calculate Textbox value based on another textbox value Tdungate Excel Discussion (Misc queries) 0 February 12th 09 07:03 PM
Excel 2007 Textbox Locking Doug Excel Discussion (Misc queries) 1 April 1st 08 02:12 PM
locking formula in cells in without locking whole sheet SuziQ Excel Discussion (Misc queries) 1 July 21st 06 03:58 PM
UserForm TextBox to ActiveSheet TextBox over 256 characters Dan E[_2_] Excel Programming 1 July 28th 03 07:36 PM


All times are GMT +1. The time now is 12:38 PM.

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

About Us

"It's about Microsoft Excel"