get value from anothe function

24sharon

Registered User.
Local time
Today, 15:05
Joined
Oct 5, 2004
Messages
147
I have a function that export 2 strings
and I want to use this strings in another sub.

here is my function:
Code:
Private Function GKS(ByVal o)
Dim sq, ss
Select Case o
Case 1
    sq = ">"
    ss = "big then"
Case 2
    sq = "<"
    ss = small then"
Case 3
    sq = "="
    ss = "is"
Case Else
    sq = "="
    ss = "is"
End Select
End Function
and here is my sub:
Code:
Private Sub mySQL()
Dim sSQL, sq, ss
Me.strSQL = ""
....
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
If Not IsNull(Me.MySum) Then [B]GKS(Me.MySum3):[/B] sSQL = sSQL & " and [MySum] "[B] & sq &[/B] Me.MySum: Me.strSQL = Me.strSQL & "ñëåí áñéñ " [B]& ss & [/B] Me.MySum & vbCrLf
MsgBox sSQL
and I didnt get the value :( (ss and sq are null)
what did I need to change?

Thanks all
 
Code:
Private Function GKS(ByVal o, ByRef sq, ByRef ss)

Select Case o
Case 1
    sq = ">"
    ss = "big then"
Case 2
    sq = "<"
    ss = small then"
Case 3
    sq = "="
    ss = "is"
Case Else
    sq = "="
    ss = "is"
End Select
End Function


Code:
Private Sub mySQL()
Dim sSQL, sq, ss
Me.strSQL = ""
....
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
If Not IsNull(Me.MySum) Then [B]GKS(Me.MySum3, sq, ss):[/B] sSQL = sSQL & " and [MySum] "[B] & sq &[/B] Me.MySum: Me.strSQL = Me.strSQL & "ñëåí áñéñ " [B]& ss & [/B] Me.MySum & vbCrLf
MsgBox sSQL
 
Thanks :)

ITS WORK...:-P

there is just a small problem.

when I call the function I have to write:

ab = GKS(Me.MySum3, sq, ss):

why did I need to write it and not just:
GKS(Me.MySum3, sq, ss):
 
24sharon said:
ab = GKS(Me.MySum3, sq, ss):

why did I need to write it and not just:
GKS(Me.MySum3, sq, ss):

A function returns a value and therefore you need to assign its value somewhere. In this case ab.

A subroutine does not return a value so you can leave the name of the sub without assigning it to anything.

So, you probably want to change Private Function GKS to Private Sub GKS
 

Users who are viewing this thread

Back
Top Bottom