How can i write a correct function: If i write a function as this:
Public Function BatterList (ByRef port as integer) as ImageList
Dim image1 as image
return image1
end function
Tom Shelton - 06 Mar 2008 19:38 GMT
> How can i write a correct function: If i write a function as this:
>
[quoted text clipped - 5 lines]
>
> end function
I fail to understand the question... Can you possibly provide more
details? Looking at your code, I am wondering the purpose of the port
argument to your function, and why it is passed ByRef - but, I am not
sure what specifically you are looking for.

Signature
Tom Shelton
Terry - 06 Mar 2008 19:39 GMT
Not really sure what your question is, but I think
dim image1 as image
should be
dim image1 as New image

Signature
Terry
> How can i write a correct function: If i write a function as this:
>
[quoted text clipped - 5 lines]
>
> end function
Armin Zingler - 06 Mar 2008 19:40 GMT
> How can i write a correct function: If i write a function as this:
>
[quoted text clipped - 5 lines]
>
> end function
http://msdn2.microsoft.com/en-us/library/6xxtk8kx.aspx
Armin
kimiraikkonen - 06 Mar 2008 19:57 GMT
> How can i write a correct function: If i write a function as this:
>
[quoted text clipped - 5 lines]
>
> end function
However in your function, "port" argument is missing and remains
unused. Also be sure that you really need "ByRef" instead of "ByVal".
Herfried K. Wagner [MVP] - 07 Mar 2008 02:10 GMT
"cmdolcet69" <colin_dolcetti@hotmail.com> schrieb:
> How can i write a correct function: If i write a function as this:
>
[quoted text clipped - 5 lines]
>
> end function
What is the 'port' parameter for?
Why is it passed by-reference?
Your function would return 'Nothing' if its return type was changed to
'Image'.
An 'Image' is not an 'ImageList'.

Signature
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Cor Ligthert[MVP] - 07 Mar 2008 04:32 GMT
cm,
I do it the same way as you, some like to write:
Return BatterList
However, because I use mostly very long names for methods (functions), I
like to return something I created or referenced in my method.
I assume that
Dim image1 as Image
was a typo and had to by in this sample
Dim image1 as ImageList
etc
Cor
> How can i write a correct function: If i write a function as this:
>
[quoted text clipped - 5 lines]
>
> end function