Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > TextBox Help


Reply
 
Thread Tools Display Modes
  #1  
Old 08-22-2003, 10:55 PM
VentureX VentureX is offline
Newcomer
 
Join Date: Aug 2003
Posts: 6
Default TextBox Help


I am building a program that that takes input from a user using a text box i want to know if there is a way to set the textbox to only take sertain input like just a and b inputs can any one help me

thanx in advance
Reply With Quote
  #2  
Old 08-22-2003, 11:01 PM
J0n J0n is offline
Junior Contributor
 
Join Date: Jun 2003
Location: Australia
Posts: 241
Default

In the keypress event of the textbox, have something like:
Code:
Private Sub Text1_KeyPress(KeyAscii As Integer) If Chr(KeyAscii) <> "a" And Chr(KeyAscii) <> "b" And KeyAscii <> 8 Then KeyAscii = 0 End Sub
The KeyAscii <> 8 is to enable backspace.
Reply With Quote
  #3  
Old 08-22-2003, 11:02 PM
PrOpHeT's Avatar
PrOpHeT PrOpHeT is offline
Hopelessly confused...

* Expert *
 
Join Date: Mar 2001
Location: Tyler, Tx.
Posts: 3,054
Default

filter the results by their keycode value in the keydown event. if they do not fit your criteria set keycode to 0
__________________
When you earnestly believe you can compensate for a lack of skill by doubling your efforts, there's no end to what you can't do ;)

For the love of Gold...
Reply With Quote
  #4  
Old 08-22-2003, 11:04 PM
VentureX VentureX is offline
Newcomer
 
Join Date: Aug 2003
Posts: 6
Default

thanx this really helped alot
Reply With Quote
  #5  
Old 08-23-2003, 12:12 AM
Squishy's Avatar
Squishy Squishy is offline
Senior Contributor
 
Join Date: Jul 2003
Location: Stratford
Posts: 919
Default

Quote:
Originally Posted by PrOpHeT
filter the results by their keycode value in the keydown event. if they do not fit your criteria set keycode to 0


KeyCode won't work. It needs to be KeyAscii in the KeyPress event.
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
TextBox Event jgbarber65 General 6 08-09-2003 04:27 AM
URGENT - How to change the display mode (ascii, ansi, unicode, etc) in a TextBox? xiaoDD General 2 06-23-2003 02:24 AM
TextBox Question unclebill General 2 04-26-2003 10:19 AM
Error in updating database thro textbox (editable msflexgrid) SURESH MENON Database and Reporting 0 03-26-2003 10:57 PM
Scroll Multiline textbox fizbim API 5 11-18-2001 04:35 PM

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
 
 
-->