Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Application Programming › Ensuring text box entry is an integer - Visual Basic .NET
New Posts  All Forums:Forum Nav:

Ensuring text box entry is an integer - Visual Basic .NET

post #1 of 3
Thread Starter 

Hi OCN,

 

I'm trying to build a program and for this program I need it to only accept integer values, so if a user enters a number such as 3.14 for example, it would reject it because of the decimal place. Basically, I want to program it so that it only accepts numbers and nothing else.

 

Here's an example of what I have now:

 

 

Public Class Form1

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        If IsNumeric(TextBox1.Text) Then
            MessageBox.Show("Yay!")
        Else
            MessageBox.Show("Nay! :(")
        End If
    End Sub
End Class

 

 

Obviously this checks to make sure that the inputted value is a numerical value, but it allows for integers to be entered as well. Do you know of any ways that I could make my program check to make sure that an integer value has been entered?

Number Cruncher
(16 items)
 
HTPC
(11 items)
 
750TIMINER2
(15 items)
 
CPUMotherboardGraphicsRAM
i7 2600k ASUS Sabertooth Z77 Sapphire 290 Tri-x 4GB OC CORSAIR Vengeance 16GB 
Hard DriveHard DriveHard DriveOptical Drive
Intel 520 120 GB SSD Seagate Barracuda 1 TB 250GB Samsung 840 EVO SSD LG Blu-Ray Lightscribe Combo Burner 
CoolingOSMonitorPower
Swiftech H320 (CPU only) Windows 7 Ultimate 27" Shimian 1440p Monitor 1000W Corsair PSU 
CaseMouseMouse PadAudio
800D custom painted and fixed up! 15 year old Microsoft Custom Minecraft Mousepad Logitech 2.1 Speakers (wub wubbity wub wub) 
CPUMotherboardGraphicsRAM
i5 3570k MSI Z68 MA-ED55 MSI GTX 750 Ti 6GB Corsair XMP 
Hard DriveOptical DriveCoolingOS
500GB WD Blue ASUS DVD Burner Hyper 212+ Windows 8.1 
PowerCase
Rosewill HIVE 750W Rosewill Blackbone 
CPUMotherboardGraphicsRAM
AMD Sempron 145 Gigabyte 990FXA-UD3 4x MSI GTX 750 Ti 6 GB Corsair XMP 
Hard DriveCoolingOSMonitor
500 GB Seagate Barracuda Stock Windows 7 LG 20" 900p display 
KeyboardPowerCaseMouse
Dell generic Rosewill HIVE 750W Rosewill Thor V2 Dell generic 
Other
4x USB Powered Risers 
  hide details  
Reply
Number Cruncher
(16 items)
 
HTPC
(11 items)
 
750TIMINER2
(15 items)
 
CPUMotherboardGraphicsRAM
i7 2600k ASUS Sabertooth Z77 Sapphire 290 Tri-x 4GB OC CORSAIR Vengeance 16GB 
Hard DriveHard DriveHard DriveOptical Drive
Intel 520 120 GB SSD Seagate Barracuda 1 TB 250GB Samsung 840 EVO SSD LG Blu-Ray Lightscribe Combo Burner 
CoolingOSMonitorPower
Swiftech H320 (CPU only) Windows 7 Ultimate 27" Shimian 1440p Monitor 1000W Corsair PSU 
CaseMouseMouse PadAudio
800D custom painted and fixed up! 15 year old Microsoft Custom Minecraft Mousepad Logitech 2.1 Speakers (wub wubbity wub wub) 
CPUMotherboardGraphicsRAM
i5 3570k MSI Z68 MA-ED55 MSI GTX 750 Ti 6GB Corsair XMP 
Hard DriveOptical DriveCoolingOS
500GB WD Blue ASUS DVD Burner Hyper 212+ Windows 8.1 
PowerCase
Rosewill HIVE 750W Rosewill Blackbone 
CPUMotherboardGraphicsRAM
AMD Sempron 145 Gigabyte 990FXA-UD3 4x MSI GTX 750 Ti 6 GB Corsair XMP 
Hard DriveCoolingOSMonitor
500 GB Seagate Barracuda Stock Windows 7 LG 20" 900p display 
KeyboardPowerCaseMouse
Dell generic Rosewill HIVE 750W Rosewill Thor V2 Dell generic 
Other
4x USB Powered Risers 
  hide details  
Reply
post #2 of 3
Integer.TryParse
Death Star
(21 items)
 
Darksaber
(11 items)
 
 
CPUMotherboardGraphicsRAM
Athlon II x2 245 Asus M3A78 Radeon HD6570 1GB Mushkin Silverline 2GB DDR2  
Hard DriveOptical DriveOSMonitor
OCZ Vertex 2 120GB Samsung Blu-Ray Windows 7 Samsung 46" DLP 
PowerCaseOther
Silverstone Strider Essentials 400W Silverstone Milo ML03B Hauppage WinTV 1250 
  hide details  
Reply
Death Star
(21 items)
 
Darksaber
(11 items)
 
 
CPUMotherboardGraphicsRAM
Athlon II x2 245 Asus M3A78 Radeon HD6570 1GB Mushkin Silverline 2GB DDR2  
Hard DriveOptical DriveOSMonitor
OCZ Vertex 2 120GB Samsung Blu-Ray Windows 7 Samsung 46" DLP 
PowerCaseOther
Silverstone Strider Essentials 400W Silverstone Milo ML03B Hauppage WinTV 1250 
  hide details  
Reply
post #3 of 3
Ol' Sandy
(28 items)
 
"Zeus"
(12 items)
 
Elite Preview
(6 items)
 
CPUMotherboardGraphicsRAM
Intel Xeon E3-1230v3 Gigabyte GA-Z97X-UD5H-BK MSI Gaming GTX 980 Kingston 32GB (4x8) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Samsung EVO 1TB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 8 Pro 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2713HM Topre Realforce 87UB | Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Logitech G700 XTRAC Ripper XXL 
AudioAudioAudioAudio
Beyerdynamic DT-770 Pro 250ohm Schiit Bifrost DAC Schiit Asgard 2 HiVi Swan M50W 2.1 
CPUMotherboardRAMHard Drive
Intel Xeon E5-2620 Super Micro X9SRL-F-B 128GB 1333MHz LSI 9271-8i 
OSPowerCase
VMware ESXi 5.5 SeaSonic SS-400FL2 Fractal Define R3 
CPUMotherboardGraphicsRAM
Intel Core i5-3437U HP EliteBook Folio 9470m  Intel HD Graphics 4000  16GB DDR3 SDRAM 
Hard DriveOS
256GB SSD Windows 10 Insider Preview 
  hide details  
Reply
Ol' Sandy
(28 items)
 
"Zeus"
(12 items)
 
Elite Preview
(6 items)
 
CPUMotherboardGraphicsRAM
Intel Xeon E3-1230v3 Gigabyte GA-Z97X-UD5H-BK MSI Gaming GTX 980 Kingston 32GB (4x8) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Samsung EVO 1TB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 8 Pro 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2713HM Topre Realforce 87UB | Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Logitech G700 XTRAC Ripper XXL 
AudioAudioAudioAudio
Beyerdynamic DT-770 Pro 250ohm Schiit Bifrost DAC Schiit Asgard 2 HiVi Swan M50W 2.1 
CPUMotherboardRAMHard Drive
Intel Xeon E5-2620 Super Micro X9SRL-F-B 128GB 1333MHz LSI 9271-8i 
OSPowerCase
VMware ESXi 5.5 SeaSonic SS-400FL2 Fractal Define R3 
CPUMotherboardGraphicsRAM
Intel Core i5-3437U HP EliteBook Folio 9470m  Intel HD Graphics 4000  16GB DDR3 SDRAM 
Hard DriveOS
256GB SSD Windows 10 Insider Preview 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Application Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Application Programming › Ensuring text box entry is an integer - Visual Basic .NET