How can I call a function from two spots?

gerunresT

New Member
If I have a function I want to call from either a button click or just from within another function how can I do it so the arguments are correct? So if I have a function:<BR><BR>sub myFunction(obj as object, e as eventargs)<BR><BR>Which allows me to call it from a button but if I try just to call <BR><BR>myFunction() <BR><BR>I get an error saying that the arguments aren't right (which they are not) but how to I do this?1. Overload the function to take two different sets of parameters.<BR><BR>2. Take the code logic out and stick it in a seperate function. Then call that function from within your myFunction -- you can safely ignore the input parameters then.How do I over load the function? I tried using the "Optional" but it requires constants to be set then so I got as far as<BR><BR>sub myFunction(optional obj as object = "OBJ", optional e as eventargs = ?????)<BR><BR>Any idea what to put in the ?????So I don't know the exact syntax, but it would be something like in C++<BR><BR>void SomeClass::SomeFunction (parameter1)<BR>void SomeClass::SomeFunction()<BR><BR><BR>Same thing, different setups... as long as the TYPE is different, you can alter them as much as you want.<BR><BR>Xander is the guy to ask for VB.Net questions...<BR><BR>
 
Back
Top