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 reads well for understanding functions in VB6
EDIT
After reading your comment, I will create a class to store your values.
Public Class MyClass Dim name As String Dim dept As String Dim country As String End Class
You can then instantiate a new instance of this class inside 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
source share