PC Review


Reply
Thread Tools Rate Thread

Calling a sub

 
 
=?Utf-8?B?Qk9CT0RE?=
Guest
Posts: n/a
 
      28th Nov 2006
Someone else posted this really useful code for validating textboxes:

Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Select Case KeyAscii
Case 48 To 57 'numbers
Case Else 'Discard anything else
Beep
KeyAscii = 0
End Select
End Sub

Only problem is that I have numerous textboxes to check and I've currently
listed this for every box.

How do I package this so that for each textbox I can use something similar to:

Private Sub txtBankNum4_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Call NumCheck
End Sub
 
Reply With Quote
 
 
 
 
=?Utf-8?B?SmltIFRob21saW5zb24=?=
Guest
Posts: n/a
 
      28th Nov 2006
Try somethin like this...

Private Sub txtBankNum4_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Call NumberValid(KeyAscii)
End Sub

Private Sub NumCheck(ByRef KeyAscii As MSForms.ReturnInteger)
Select Case KeyAscii
Case 48 To 57 'numbers
Case Else 'Discard anything else
Beep
KeyAscii = 0
End Select
End Sub
--
HTH...

Jim Thomlinson


"BOBODD" wrote:

> Someone else posted this really useful code for validating textboxes:
>
> Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
> Select Case KeyAscii
> Case 48 To 57 'numbers
> Case Else 'Discard anything else
> Beep
> KeyAscii = 0
> End Select
> End Sub
>
> Only problem is that I have numerous textboxes to check and I've currently
> listed this for every box.
>
> How do I package this so that for each textbox I can use something similar to:
>
> Private Sub txtBankNum4_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
> Call NumCheck
> End Sub

 
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
Calling SQL from code has different behaviour than calling it from MS SQL Server Management Studio jeeji Microsoft C# .NET 1 29th Jun 2006 10:43 AM
Calling DoCmd.RunCommand acCmdSaveRecord, after calling an API function Savvoulidis Iordanis Microsoft Access Form Coding 2 19th Mar 2005 06:34 PM
Fail to send fax when making international fax calling / calling c =?Utf-8?B?c2Ftd2lzZQ==?= Windows XP Help 1 28th Dec 2004 02:31 PM
Calling FormsAuthentication.SignOut() after calling Response.Flush =?Utf-8?B?TWFydGluIExlZQ==?= Microsoft ASP .NET 1 28th Sep 2004 01:47 PM
Server Side button calling page_load before calling it's own click event. Ryan Ternier Microsoft ASP .NET 4 29th Jul 2004 02:06 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:40 PM.