Solved

Return Values from a function

Posted on 2001-06-05
3
124 Views
Last Modified: 2010-05-02
Hello all,
I am new to VB, and I would like to know how to pick up the return value of a function (any function)?

any suggestions
P
0
Comment
Question by:Peridot
3 Comments
 
LVL 4

Accepted Solution

by:
TigerZhao earned 100 total points
ID: 6155355
Function f() As Long
    f = 1
End Function

Sub Main()
    Dim l As Long

    l = f()
    Debug.Print l
End Sub
0
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 6155359
Hi, here is a sample:

___________________________________________

use like this: Text1.Text = returnValue(3)

Private Function returnValue(ByVal ivalue As Integer) As String
    Select Case ivalue
    Case 0
        returnValue = "A"
    Case 1
        returnValue = "B"
    Case 2
        returnValue = "C"
    Case Else
        returnValue = "D"
    End Select
End Function

'Hope will help.
0
 

Author Comment

by:Peridot
ID: 6155375
Thanks TigerZhao.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

706 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

17 Experts available now in Live!

Get 1:1 Help Now