Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / March 2008

Tip: Looking for answers? Try searching our database.

Writing a correct function

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
cmdolcet69 - 06 Mar 2008 18:59 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.