Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27349

Handle 'Argument Exception'

$
0
0
Hello guys!

I am trying to find a way to handle the argument exception errors.
I am making a small program with economic functions and I have an issue when I get the ''argument exception'' error.

This is a sample of the code:

Code:

   
Dim PAYMENT,SPV,R,PERIODS AS DOUBLE     
PAYMENT = Val(TextBox1.Text) 'PAYMENT
SPV = Val(TextBox2.Text) 'PRESENT VALUE
R = Val(TextBox3.Text) 'RATE
PERIODS = NPer(R, PAYMENT, SPV, 0)
TextBox5.Text = Format(PERIODS, "STANDARD")

The problem is that if I type random numbers (e.g PAYMENT>SPV or PAYMENT>0 AND SPV>0 ) I get
the argument exception problem because the output is wrong and has no economic meaning.

How can I overcome this problem? I was thinking a checking code like this:

If argument exception ..... then
messagebox .....
exit sub
End if

Is it possible something like this?

Best regards
stratos

Viewing all articles
Browse latest Browse all 27349

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>