|
-
Jul 9th, 2004, 02:14 AM
#1
Thread Starter
New Member
How to put numbers/float only on textboxes
Hello Im new to these forums. Im using VB for our thesis and Im just wondering how to be able to put numbers only on text boxes without causing an error.
-
Jul 9th, 2004, 03:25 AM
#2
Addicted Member
We can only put text into textboxes.
Where we need numbers the entry needs to be converted in some way. The easiest way is to get Excel to do the conversion by declaring a variable. eg.
Code:
Dim MyNumber As Double
MyNumber = TextBox1.Value
Regards
BrianB
-------------------------------
-
Jul 9th, 2004, 05:07 AM
#3
Thread Starter
New Member
That's what I do:
nSNR = CInt(txtNoise.Text)
And as soon as I type a non-number character...
-
Jul 10th, 2004, 01:51 PM
#4
VB Code:
Option Explicit
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii <> 46 And KeyAscii <> 48 And KeyAscii <> 49 And KeyAscii <> 50 Then 'Etc.
KeyAscii = vbNull
End If
End Sub
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 
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
|