finding the wrong argument

  • Thread starter Thread starter Rudy
  • Start date Start date
R

Rudy

I have a method which has a large numbers of arguments (of integers) say
30. When one of the arguments are wrong (null or the argument is not an
integer), vb.net (2005) reports that there is an error. The problem is that
in debug mode vb.net does not say which argument is wrong, it only gives the
line where it happens.

Is there as way to see which argument has thrown the error?

Rudy
 
I have a method which has a large numbers of arguments (of integers) say
30. When one of the arguments are wrong (null or the argument is not an
integer), vb.net (2005) reports that there is an error. The problem is that
in debug mode vb.net does not say which argument is wrong, it only gives the
line where it happens.

Is there as way to see which argument has thrown the error?

Rudy

If you want the arguments to be an integer, then why don't you declare
it as an integer parameter? This will throw a compile time error if
you try to pass in an invalid value.

i.e. Change:

////////////////////
Public Sub Foo(arg1 as Object, arg2 as Object, ....)

End Sub
///////////////////

to:

////////////////////
Public Sub Foo(arg1 as Integer, arg2 as Integer, .....)

End Sub
///////////////////

Also, I'm guessing you do not have Option Strict On, which you should
immediately turn in on to save yourself a lot of headaches later.

Thanks,

Seth Rowe
 
I have this:
////////////////////
Public Sub Foo(arg1 as Integer, arg2 as Integer, .....arg30 as integer)

End Sub
///////////////////

When I do:

Foo(12,23,"x"...)

There comes an error. The "problem" is that the compiler does not say "hey
invalid argument 'arg3' you put an 'x' where it should be an integer".
But it just saying "hey 'x' is not an integer", I have to check manualy all
the arguments, and if you have a large number of arguments (of mixed types)
it can take some time to find the wrong argument.

Rudy
 
I have this:





When I do:

Foo(12,23,"x"...)

There comes an error. The "problem" is that the compiler does not say "hey
invalid argument 'arg3' you put an 'x' where it should be an integer".
But it just saying "hey 'x' is not an integer", I have to check manualy all
the arguments, and if you have a large number of arguments (of mixed types)
it can take some time to find the wrong argument.

Rudy

Did you turn on Option Strict like I told you to?

Thanks,

Seth Rowe
 
Back
Top