i have
Public Function ShowMyDate(ByVal dtmDate As Date, ByVal bytDate As
Short) As
String
I get an error if the combobox is "". Which will lead me into the
next question
Me.Label7.Text = i.ShowMyDate(Date.Today(), Me.ComboBox2.Text) in a
form
Your ShowMyDate function is requiring a Short for the second parameter, but
you are passing a string (me.combobox2.text). If you turn Option Strict On,
this should become apparent at compile time rather than runtime. Additionally,
you should always evaulate the validity of the parameters coming into your
method to make sure the right type is being passed. Consider the following:
public Function FormatFoo(ByVal foo as string) as string
Return foo.ToUpper
end function
This method would fail if you pass it Nothing (which is possible if you send
it the value of me.ComboBox2.Text when no value is selected). It is better
to do the following:
public Function FormatFoo(ByVal foo as string) as string
if foo.IsNullOrEmpty then
Return String.Empty
else
Return foo.ToUpper
end if
end function
In your case, I would recommend you evaluate dtmDate and bytDate to make
sure they are not Nothing before trying to use them.
Where can i find info on custom errors?
Search (using your favorite search engine) "custom exception". Be aware that
the recommendation has moved from inheriting from ApplicationException toward
inheriting from Exception.
Jim Wooley
http://devauthority.com/blogs/jwooley/default.aspx