Solved

Return Values from a function

Posted on 2001-06-05
3
131 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 52

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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month7 days, 7 hours left to enroll

632 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