VB School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

 

Code Snippets

  

Visual Basic Source Code


Welcome to Dream.In.Code
Become a VB Expert!

Join 300,354 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,797 people online right now. Registration is fast and FREE... Join Now!





Input Validations

This snippet will only allow the user to input letters in a textbox

Submitted By: birdflu9999
Actions:
Rating:
Views: 218

Language: Visual Basic

Last Modified: July 3, 2009
Instructions: 1. add the function to a module or to your form
2. you must use it under the event "KeyPress" of a textbox

3. it will look like this:

Private Sub Text1_KeyPress(KeyAscii As Integer)
LettersOnly KeyAscii
End Sub

Snippet


  1. Function LettersOnly(KeyAscii As Integer)
  2.     Select Case KeyAscii
  3.     Case Asc("a") To Asc("z")
  4.     Case Asc("A") To Asc("Z")
  5.     Case Str(32)    'Space
  6.     Case Str(13)    'Enter
  7.     Case Str(8)     'Backsapce
  8.     Case Str(164)   
  9.     Case Str(165)   
  10.     Case Else
  11.         KeyAscii = 0
  12.     End Select
  13. End Function

Copy & Paste


Comments


There are currently no comments for this snippet. Be the first to comment!

Add comment


You must be registered and logged on to </dream.in.code> to leave comments.





Live VB Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month