Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Source] Allowed Characters in Textbox / Richtextbox
#1
The gui is derive from this forum. hehehe Yeye

[Image: oDCQl.png]

I just used simple codes and used in keypress event.
Full Codes:
Code:
Public Class Form1

    Private Sub RichTextBox1_KeyPress(ByVal sender As Object, _
                                      ByVal e As System.Windows.Forms.KeyPressEventArgs) _
                                      Handles RichTextBox1.KeyPress

        If (e.KeyChar < "a" OrElse e.KeyChar > "z") AndAlso (e.KeyChar < "A" OrElse e.KeyChar > "Z") Then
            e.Handled = True
        End If
    End Sub

    Private Sub RichTextBox2_KeyPress(ByVal sender As Object, _
                                      ByVal e As System.Windows.Forms.KeyPressEventArgs) _
                                      Handles RichTextBox2.KeyPress

        If e.KeyChar < "0" Or e.KeyChar > "9" Then
            e.Handled = True
        End If
    End Sub
End Class

Edit: Ooops I have a grammar error in the description.
USB Anti-virus? Try USB Drive Defender
[Image: 8bQCusS.jpg]
Reply
#2
You also need to allow keys like backspace to be pressed. Don't forget that...Nice gui anyway Smile
My software company: Porosis Software
Games: Terrantula
Apps: Mathanasis, ColorGrabber
Reply
#3
(05-16-2011, 05:26 AM)thanasis2028 Wrote: You also need to allow keys like backspace to be pressed. Don't forget that...Nice gui anyway Smile

Tested in Windows 7, backspace is working fine.
USB Anti-virus? Try USB Drive Defender
[Image: 8bQCusS.jpg]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  how to display google captcha picture on form and add to textbox hit ok to bypass polas 0 1,265 09-14-2012, 01:59 PM
Last Post: polas
  [Source ] Hemp Tycoon App [/Source] VB.net KoBE 8 9,734 03-05-2012, 10:30 PM
Last Post: SomeWhiteGuy?
  [Source]Sql Database Project [Source] Digital-Punk 0 1,437 10-16-2011, 07:01 AM
Last Post: Digital-Punk
  [Source]Batch to Exe converter[Source] Digital-Punk 6 2,976 10-15-2011, 03:00 AM
Last Post: Digital-Punk
  [Release] TextBox Color Changer [Release] Resistance 23 6,946 10-14-2011, 02:55 PM
Last Post: Resistance

Forum Jump:


Users browsing this thread: 1 Guest(s)