PC Review


Reply
Thread Tools Rate Thread

How to control TextBox ?

 
 
Golenboy
Guest
Posts: n/a
 
      27th Mar 2007
Hello all
I will have to develop a userform and I want to control the value of
TextBox which must be an integer not null. What do I have to do? I
wrote this but it is not the good code!!

Private Sub TextBoxl_Change()

Dim KeyAscii As MSForms.ReturnInteger

Select Case KeyAscii
Case Is < 49, Is > 57
MsgBox "Only a non null interger is allowed."
KeyAscii = Asc(Chr(8))
End Select

End Sub

 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      27th Mar 2007
Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Select Case KeyAscii
Case Is < 49, Is > 57
MsgBox "Only a non null interger is allowed."
KeyAscii = 0
End Select

End Sub


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Golenboy" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello all
> I will have to develop a userform and I want to control the value of
> TextBox which must be an integer not null. What do I have to do? I
> wrote this but it is not the good code!!
>
> Private Sub TextBoxl_Change()
>
> Dim KeyAscii As MSForms.ReturnInteger
>
> Select Case KeyAscii
> Case Is < 49, Is > 57
> MsgBox "Only a non null interger is allowed."
> KeyAscii = Asc(Chr(8))
> End Select
>
> End Sub
>



 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      27th Mar 2007
As a user, I wouldn't want to dismiss that dialog each time I made a typo. But
I liked the beep.

I changed Bob's code to:

Option Explicit
Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Select Case KeyAscii
Case Is < 49, Is > 57
'MsgBox "Only an integer is allowed."
KeyAscii = 0
Beep
End Select
End Sub



Golenboy wrote:
>
> Hello all
> I will have to develop a userform and I want to control the value of
> TextBox which must be an integer not null. What do I have to do? I
> wrote this but it is not the good code!!
>
> Private Sub TextBoxl_Change()
>
> Dim KeyAscii As MSForms.ReturnInteger
>
> Select Case KeyAscii
> Case Is < 49, Is > 57
> MsgBox "Only a non null interger is allowed."
> KeyAscii = Asc(Chr(8))
> End Select
>
> End Sub


--

Dave Peterson
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use reflection on textbox control to allow program control of scrolling? notu Microsoft Dot NET Compact Framework 3 7th Jul 2005 07:03 AM
Setting the Control source of a textbox to a query based on the valueof another textbox on the same form Joey Microsoft Access Queries 1 26th Jan 2005 03:35 AM
Re: How to move cursor from one textbox control to another textbox con Tom Ogilvy Microsoft Excel Programming 1 16th Sep 2004 03:42 PM
How to move cursor from one textbox control to another textbox con =?Utf-8?B?S01vb3JlMDA3?= Microsoft Excel Programming 0 16th Sep 2004 02:47 PM
Re: VERY STRANGE BUG? Adding a textbox control causes other textbox control to fail??? S. Justin Gengo Microsoft ASP .NET 0 16th Jul 2003 07:51 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:52 AM.