Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > I need to cancel/abort the Keydown event on a textbox


Reply
 
Thread Tools Display Modes
  #1  
Old 10-13-2004, 04:31 AM
Stuey Stuey is offline
Regular
 
Join Date: Jan 2004
Posts: 67
Default I need to cancel/abort the Keydown event on a textbox


I need to evaluate the keycode the user has entered (this is the easy part) and then let the procedure either proceed OR concel the event so that the keypress doesn't end up in the textbox.

I seem to remember a 'cancel event' type command in Access Basic but can't find the equivelant in VB.

Failing that do you have any tips on input masks 'cause I don't seem to be able to make the MSMask control work (I get an error when I try to place a total into one of them).

Thank you for your time.

Stuey
Reply With Quote
  #2  
Old 10-13-2004, 12:14 PM
quarque's Avatar
quarque quarque is offline
Junior Contributor
 
Join Date: Sep 2004
Location: Seattle
Posts: 211
Default

perhaps try setting the keycode to 0 which won't go into the textbox(?)
Reply With Quote
  #3  
Old 10-13-2004, 01:00 PM
Rashka's Avatar
Rashka Rashka is offline
Contributor
 
Join Date: May 2004
Location: Ohio, USA
Posts: 771
Default

Could you please explain a little more?
By masks, do you mean having *** in the textbox instead of abc?
Is the textbox only supposed to accept numbers, or a specific range of letters?

Without my crystal ball, I can only guess at what you are looking for.
__________________
Brandon

Once you embrace the idea that your customers deserve to die...
...it frees your mind to invent splendidly profitable products - Dogbert
Reply With Quote
  #4  
Old 10-13-2004, 02:59 PM
Agent707 Agent707 is offline
Retired Contributor
 
Join Date: Mar 2002
Posts: 1,829
Default

Like quarque said...
Code:
Private Sub Text1_KeyPress(KeyAscii As Integer) Select Case KeyAscii Case w,x,y,z 'Where w,x,y,z are any Ascii numbers you do not want to be entered. KeyAscii = 0 End Select End Sub
Edit: Actually, better to use the KeyAscii numbers...

Last edited by Agent707; 10-13-2004 at 03:09 PM.
Reply With Quote
  #5  
Old 10-13-2004, 03:00 PM
Halor Halor is offline
Newcomer
 
Join Date: Oct 2004
Posts: 12
Default

I think he is wanting some sort of authentication such as a password or seriel code, you could do it with a text box and a button, the code below is a simple password code that could technically be used for seriel codes also.

Code:
Private Sub cmdCode_Click() If txtCode.Text = "code1" Or "code2" Or "code3" Then 'I think OR would work if you have multiple codes, not sure though, i am a tad of a nub MsgBox "Correct Code", 8, "Message Box" 'If they put in one of the correct codes, it displays this Form1.cmdStart.Enabled = True 'Do something, in my program I had it activate the start and stop button in form1 Form1.cmdStop.Enabled = True 'ditto Else MsgBox "Wrong Code", 8, "Message Box" 'Wrong code punk <.< End If Form4.Hide 'Hides the password/authentication form (mine being form4) after they put in a right or wrong code End Sub

I'm probably wrong though, so ignore me..
__________________
"Faith; noun. Belief without evidence in what is told by one who speaks without knowledge, of things without parallel." --- Ambrose Bierce

Last edited by Halor; 10-13-2004 at 03:05 PM.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->