passing variables

ScientificLee
09-03-2003, 11:31 AM
Hello.

Let's say that I have a sub as such.
Sub setVars(symbol As String, startTime As String, endTime As String)
If Weekday(Now - 1) = vbSunday Then
stDate = Year(Now) & "/" & Month(Now) & "/" & Day(Now - 3)
Else
stDate = Year(Now) & "/" & Month(Now) & "/" & Day(Now - 1)
End If
stMachine = "&HISTORIC&"
stService = "TA_SRV"
stTopic = "LIVECHART"
stItem = "TICKS;1006,1178;9008='" & stDate & "',1003='& symbol & ',9004=1,9009=' & startTime & ',9010='& endTime & '"
End Sub


can I just call this sub later as
Sub connectTAL(symbol As String, startTime As String, endTime As String)
setVars(symbol, startTime, endTime)
end sub

Thinker
09-03-2003, 11:34 AM
No. If you are going to pass the parameters inside (), you need the
Call keyword in front. Otherwise, with subs you leave off the ().

ScientificLee
09-03-2003, 12:13 PM
Thank you.
So I the correct syntax would be


Call setVar(symbol, startTime, endTime)

Thinker
09-03-2003, 02:30 PM
That is fine but personally, I don't use the Call syntax. I think it is left
in for backward compatibility and I don't care much for how it looks.

ScientificLee
09-03-2003, 02:32 PM
If call is not the prefered way what is?

ScientificLee
09-03-2003, 02:34 PM
Sorry, didn't read your post carefully.


callVar symbol, startTime, endTime


This is valid syntax?

ScientificLee
09-03-2003, 02:35 PM
setVar symbol, startTime, endTime


Even

Thinker
09-03-2003, 02:45 PM
Yes, both are equivalent, so it is a matter of taste.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum