Writing a correct function

  • Thread starter Thread starter cmdolcet69
  • Start date Start date
C

cmdolcet69

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
 
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

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.
 
Not really sure what your question is, but I think
dim image1 as image
should be
dim image1 as New image
 
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

However in your function, "port" argument is missing and remains
unused. Also be sure that you really need "ByRef" instead of "ByVal".
 
cmdolcet69 said:
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

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'.
 
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
 
Back
Top