|
-
Jul 8th, 2008, 11:34 PM
#1
Thread Starter
Addicted Member
[ask] textbot_changed
i have a code
Code:
Private Sub txt1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txt1.TextChanged
Dim a As Integer
txt1.SelectionStart = txt1.Text.Length
a = txt1.SelectionStart
If status = True And (Chr(Asc(txt1.SelectedText(a))) < Chr(48) Or Chr(Asc(txt1.SelectedText(a))) > Chr(57)) And Chr(Asc(txt1.SelectedText(a))) <> Chr(8) Then
MsgBox("Only numeric text", MsgBoxStyle.OkOnly)
txt1.Text = Chr(0)
txt1.Focus()
End If
End Sub
i want to make a checking everytime i input a character
it's checking is it a numeric or not
plz help me
thx
-
Jul 8th, 2008, 11:48 PM
#2
Re: [ask] textbot_changed
The TextChanged event does fire each time a change is made in the textbox like a single character keypress.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jul 9th, 2008, 12:16 AM
#3
Re: [ask] textbot_changed
You should be using the KeyPress event for this. You can test the character before it is added to the control instead of after. There are NUMEROUS examples on the forum of limiting input in TextBoxes using this technique so I'd suggest a search.
-
Jul 9th, 2008, 12:17 AM
#4
Re: [ask] textbot_changed
Just use this:
Code:
Private Sub txt1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txt1.KeyPress
'Editing
End Sub
Last edited by MaximilianMayrhofer; Jul 9th, 2008 at 12:25 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|