Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7010853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:03:10+00:00 2026-05-27T22:03:10+00:00

How to return the value from function Code Private Function LeaveCheck(empid As String) Dim

  • 0

How to return the value from function

Code

Private Function LeaveCheck(empid As String)
    Dim rdoRs1 As rdoResultset
    Dim desc As String
    Dim sSQL As String
    sSQL = "Select name from table1 wher empcode = '" & empid & "'"
    Set rdoRs1 = Rdoconn.OpenResultset(sSQL, rdOpenStatic)
    If rdoRs1.RowCount > 0 Then
    desc = rdors1!name        
    return desc 'Showing error in this line    
    End If
    rdoRs1.Close
End Function

How to return the value from the above code.

Need Vb6 code Help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T22:03:11+00:00Added an answer on May 27, 2026 at 10:03 pm

    You need to specify your return type.

    Private Function LeaveCheck(empid As String) As String ' Notice the As String
        Dim rdoRs1 As rdoResultset  
        Dim desc As String  
        Dim sSQL As String  
        sSQL = "Select name from table1 wher empcode = '" & empid & "'"  
        Set rdoRs1 = Rdoconn.OpenResultset(sSQL, rdOpenStatic)  
        If rdoRs1.RowCount > 0 Then  
            desc = rdors1!name          
        End If  
        rdoRs1.Close  
    
        LeaveCheck = desc ' This will be blank or populated
    End Function
    

    Here is a link that is a good read for understanding Functions in VB6

    EDIT

    After reading your comment, I would create a class to store your values.

    Public Class MyClass
        Dim name As String
        Dim dept As String
        Dim country As String
    End Class
    

    Then, you can instantiate a new instance of this class inside of your code:

    Private Function LeaveCheck(empid As String) As MyClass
        Dim myClass As New MyClass
        Dim rdoRs1 As rdoResultset
        Dim sSQL As String   
        sSQL = "Select name, dept, country from table1 wher empcode = '" & empid & "'"   
        Set rdoRs1 = Rdoconn.OpenResultset(sSQL, rdOpenStatic)   
        If rdoRs1.RowCount > 0 Then   
            myClass.name = rdors1!name           
            myClass.dept = rdors1!dept
            myClass.country = rdors1!country
        End If   
        rdoRs1.Close   
    
        LeaveCheck = myClass
    End Function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to get the 'nth' return value from a function without having
In order to return a value from a VB.NET function one can assign a
I'm trying to return a value from (transport) to the calling function, but can't
If you return a value (not a reference) from the function, then bind it
Im trying to return the value that a $ajax call returns, from a function
Why might my GetRawData declared function return a correct value when called from my
im trying to return a string value from a method inside my script tag
I need to return multiple values from a ColdFusion function in an ajax callback
I want to return a set of values from function till the point they
Is there a preferred way to return multiple values from a C++ function? For

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.