Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Run-time error on VB.NET
New Posts  All Forums:Forum Nav:

Run-time error on VB.NET

post #1 of 5
Thread Starter 
Here is the function procedure I scripted that will be used by another module/procedure:

Private Function ErrorFlag() As Boolean
Dim FatDecimal As Decimal
ErrorFlag = False
If Decimal.Parse(FatTextBox.Text) < 0 Then
MessageBox.Show("Please enter zero or a positive value for Fat", "Invalid Number", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
FatTextBox.Focus()
ErrorFlag = True
Else
Try
FatDecimal = Decimal.Parse(FatTextBox.Text)
Catch
MessageBox.Show("Please enter a numeric value for Fat", "Missing or Non-numeric Data", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
FatTextBox.Focus()
ErrorFlag = True
End Try
End If

End Function

The underlined line is the part that is highlighted on VB.NET when there is a run time error.

The error happens when I enter a non-numeric value in FatTextBox. The catch line is supposed to catch the error, however, and display the error message. For some reason it does not work.

The first message box pops up fine whenever I enter a negative value.

I believe it has something to do with the parsing because when I get rid of the parsing, I do not get the run-time error.

Help!
Edited by ThumperSD - 11/5/11 at 12:03pm
Random name
(16 items)
 
  
CPUMotherboardGraphicsRAM
i7 4930k Asus P9X79 LE ATI HD5850 G.SKILL 4x4gb 2133mhz 
Hard DriveHard DriveCoolingOS
Samsung EVO 840 Seagate Barracuda Noctua NH-D14 W 8.1 
MonitorKeyboardPowerCase
Dell 24" 1920x1200 Tt eSports Poseiden brown Seasonic X-850 Fractal F4 
MouseMouse PadAudioAudio
Logitech G9x Steelseries Musiland 02 DAC KRK RP5 & Dayton SUB-80 
  hide details  
Reply
Random name
(16 items)
 
  
CPUMotherboardGraphicsRAM
i7 4930k Asus P9X79 LE ATI HD5850 G.SKILL 4x4gb 2133mhz 
Hard DriveHard DriveCoolingOS
Samsung EVO 840 Seagate Barracuda Noctua NH-D14 W 8.1 
MonitorKeyboardPowerCase
Dell 24" 1920x1200 Tt eSports Poseiden brown Seasonic X-850 Fractal F4 
MouseMouse PadAudioAudio
Logitech G9x Steelseries Musiland 02 DAC KRK RP5 & Dayton SUB-80 
  hide details  
Reply
post #2 of 5
It looks like you only have the second parse function in a try/catch statement.
The New Guy
(16 items)
 
  
CPUMotherboardGraphicsRAM
Q6600 G0@3.0GHz GA-P35-DS3L EVGA 8800GT Superclocked 4GB Corsair XMS2 DDR2 800 
Hard DriveHard DriveOptical DriveOS
Seagate 320GB 7200RPM Western Digital Caviar Black Lite-on DVD burner Windows 7 Professional x64 
MonitorKeyboardPowerCase
Samsung 225BW Filco Majestouch Ninja (full keyboard w/browns) Cooler Master Xtreme 650 Antec 900 
MouseAudioAudio
Logitech MX518 Denon AHD-2000 Sennheiser HD595 
  hide details  
Reply
The New Guy
(16 items)
 
  
CPUMotherboardGraphicsRAM
Q6600 G0@3.0GHz GA-P35-DS3L EVGA 8800GT Superclocked 4GB Corsair XMS2 DDR2 800 
Hard DriveHard DriveOptical DriveOS
Seagate 320GB 7200RPM Western Digital Caviar Black Lite-on DVD burner Windows 7 Professional x64 
MonitorKeyboardPowerCase
Samsung 225BW Filco Majestouch Ninja (full keyboard w/browns) Cooler Master Xtreme 650 Antec 900 
MouseAudioAudio
Logitech MX518 Denon AHD-2000 Sennheiser HD595 
  hide details  
Reply
post #3 of 5
Thread Starter 
The second parse is not what is causing the error, however. The underline parsing statement worked fine in another procedure (regular click procedure) I used that does not involve a function procedure.
Random name
(16 items)
 
  
CPUMotherboardGraphicsRAM
i7 4930k Asus P9X79 LE ATI HD5850 G.SKILL 4x4gb 2133mhz 
Hard DriveHard DriveCoolingOS
Samsung EVO 840 Seagate Barracuda Noctua NH-D14 W 8.1 
MonitorKeyboardPowerCase
Dell 24" 1920x1200 Tt eSports Poseiden brown Seasonic X-850 Fractal F4 
MouseMouse PadAudioAudio
Logitech G9x Steelseries Musiland 02 DAC KRK RP5 & Dayton SUB-80 
  hide details  
Reply
Random name
(16 items)
 
  
CPUMotherboardGraphicsRAM
i7 4930k Asus P9X79 LE ATI HD5850 G.SKILL 4x4gb 2133mhz 
Hard DriveHard DriveCoolingOS
Samsung EVO 840 Seagate Barracuda Noctua NH-D14 W 8.1 
MonitorKeyboardPowerCase
Dell 24" 1920x1200 Tt eSports Poseiden brown Seasonic X-850 Fractal F4 
MouseMouse PadAudioAudio
Logitech G9x Steelseries Musiland 02 DAC KRK RP5 & Dayton SUB-80 
  hide details  
Reply
post #4 of 5
Quote:
Originally Posted by ThumperSD View Post
The second parse is not what is causing the error, however. The underline parsing statement worked fine in another procedure (regular click procedure) I used that does not involve a function procedure.
He's saying that you're not catching the first error because the statement that causes the error is not in the try block. Move the statement into the a try->catch block to get more clarification on what is causing the issue.
Wings
(9 items)
 
  
CPUMotherboardGraphicsRAM
Core i7 2600k Gigabyte Z68X-UD3H MSI N560-GTX-Ti-Hawk Corsair Vengeance 
Hard DriveCoolingOSPower
Samsung F4 Corsair H100 Windows 7 Ultimate x64 Corsair AX850 
Case
Corsair Obsidian 650D 
  hide details  
Reply
Wings
(9 items)
 
  
CPUMotherboardGraphicsRAM
Core i7 2600k Gigabyte Z68X-UD3H MSI N560-GTX-Ti-Hawk Corsair Vengeance 
Hard DriveCoolingOSPower
Samsung F4 Corsair H100 Windows 7 Ultimate x64 Corsair AX850 
Case
Corsair Obsidian 650D 
  hide details  
Reply
post #5 of 5
Thread Starter 
Thanks guys

Fixed it
Random name
(16 items)
 
  
CPUMotherboardGraphicsRAM
i7 4930k Asus P9X79 LE ATI HD5850 G.SKILL 4x4gb 2133mhz 
Hard DriveHard DriveCoolingOS
Samsung EVO 840 Seagate Barracuda Noctua NH-D14 W 8.1 
MonitorKeyboardPowerCase
Dell 24" 1920x1200 Tt eSports Poseiden brown Seasonic X-850 Fractal F4 
MouseMouse PadAudioAudio
Logitech G9x Steelseries Musiland 02 DAC KRK RP5 & Dayton SUB-80 
  hide details  
Reply
Random name
(16 items)
 
  
CPUMotherboardGraphicsRAM
i7 4930k Asus P9X79 LE ATI HD5850 G.SKILL 4x4gb 2133mhz 
Hard DriveHard DriveCoolingOS
Samsung EVO 840 Seagate Barracuda Noctua NH-D14 W 8.1 
MonitorKeyboardPowerCase
Dell 24" 1920x1200 Tt eSports Poseiden brown Seasonic X-850 Fractal F4 
MouseMouse PadAudioAudio
Logitech G9x Steelseries Musiland 02 DAC KRK RP5 & Dayton SUB-80 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Run-time error on VB.NET