Get value back from a sub...

Posted on 2005-05-08
Last Modified: 2010-04-23

I want to do something in a sub and then it should give back a value

I know that it can be done something like this:

return = copyfile("c:\test.test")
if return = "ok" then
Do something
Do something else
end if

Private sub copyfile(file as string)
Do something
        => HOW CAN I HERE GIVE BACK AN ok if I succeeded?
End sub


Question by:Ruttensoft
    LVL 13

    Accepted Solution

    FUNCTION is the name of a sub with a return value
    Private Function DoSomething(whatever as String) as Double
    ... do something
       Dim ReturnValue as Double
       ReturnValue = 1 +5 * 8 + 1
       Return ReturnValue
    End Function

    Return -> will pass the value back to the caller. I.e.
    if DoSomething("myname") = 42 then ....

    Author Comment

    LVL 13

    Expert Comment

    Very welcome :) sometimes the easy things are the hardest to find :)

    Author Comment

    Yeah :)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Article by: jpaulino
    XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String ( Literal, only instead of starting and ending with w…
    Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now