Re: checking for correct Chr in string

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Piet;Thanks for reply, which seems to be just what I seek. Only problem I
have is: how do I call this sub?
I'm entering "Text0KeyPress in my keypress event for my cbo, but I'm getting
errmsg "sub or function not defined. (with or without the parenteses). What
am I missing?
TIA, Richard

pietlinden@xxxxxxxxxxx wrote:
I have a cbo in which are entered surname,prename;Date of birth. It is
important that the comma be a comma, and that the semicolon be a semicolon.
[quoted text clipped - 6 lines]
--
Message posted via http://www.accessmonster.com

This is a mutant, but it's a test/example. If you trap the key pressed
in the KeyPress event of your control, you can reject/discard the
characters you don't want in your control. The following code rejects
the semi-colon, period, and colon.

Private Sub Text0_KeyPress(KeyAscii As Integer)
'---Use this if you want to the code to respond differently to
different keys
' Select Case KeyAscii
' Case 46 'period
' KeyAscii = 0
' Case 58 'colon, I think...
' KeyAscii = 0
' Case 59 'semi-colon
' KeyAscii = 0
' Case Else 'do nothing
' End Select

'---or this one if you just want to throw away/ignore a fixed set of
keys.
Select Case KeyAscii
Case 58, 46, 59 '---list of the asc(":") values that you want
to reject
KeyAscii = 0
Case Else 'do nothing
End Select
End Sub

yes, it's a screwy example. You'd use one or the other....

--
Message posted via http://www.accessmonster.com

.



Relevant Pages

  • CSV dB script help
    ... # It uses the order of those keys for the order it displays them. ... # printpagesub and prepares the date for the writeupdate# ... # We need the array, ... foreach $num ...
    (comp.lang.perl.misc)
  • Re: CSV dB script help
    ... > # It uses the order of those keys for the order it displays them. ... > # printpagesub and prepares the date for the writeupdate# ... > # We need the array, ... > foreach $num ...
    (comp.lang.perl.misc)
  • Re: software engineering, program construction
    ... I am using the keys to do other things, so yes, I need the keys, but ... sub step_one ... since the subs are still scribbling on global state. ... What I wrote above isn't in 'a functional style'. ...
    (comp.lang.perl.misc)
  • Re: Access key problem
    ... There is no general managed way in .NET 1.1 to show accelerator keys ... End Sub ... ByVal wParam As Int32, _ ... Public Sub MakeAcceleratorsVisible(ByVal Control As Control) ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Filter subform
    ... subform that I want to display related data from another table. ... form is to locate keys in subform B that are CLOSE to keys in form A. The ... Private Sub Form_Current ...
    (microsoft.public.access.formscoding)