charon
01-28-2003, 05:08 AM
Hi,
I have a bit problem on creating sub rountine. Just confused some of the things.
1.) If the subrountine contain the Global Variables which I need to share all over a page, would it be ok for me not to pass the values. I ask this question is because I found that most of the sub routine do pass the value. For intances:
Sub Count(Num1, Num2)
Total = Num 1 + Num 2
End Sub
My Sub Rountine is as below:
Sub AllField()
i = 1
Do While InStr(1, AllFields, ",", 1) <> 0
CommaLoc = InStr(1, AllFields, ",", 1)
FieldInForm(i) = Trim(Left(AllFields, CommaLoc - 1))
AllFields = Right(AllFields, Len(AllFields) - CommaLoc)
i = i + 1
Loop
FieldInForm(i) = Trim(AllFields)
TotalFields = i
End Sub
The variable such as FieldInForm(i), CommaLoc will be used outside the Sub routine, except AllFields which just used in Sub-Routine.
2.) Is there a problem if we din't declare the variable used in the sub routine (as above, the total variable).
Confusing......
please advice!
I have a bit problem on creating sub rountine. Just confused some of the things.
1.) If the subrountine contain the Global Variables which I need to share all over a page, would it be ok for me not to pass the values. I ask this question is because I found that most of the sub routine do pass the value. For intances:
Sub Count(Num1, Num2)
Total = Num 1 + Num 2
End Sub
My Sub Rountine is as below:
Sub AllField()
i = 1
Do While InStr(1, AllFields, ",", 1) <> 0
CommaLoc = InStr(1, AllFields, ",", 1)
FieldInForm(i) = Trim(Left(AllFields, CommaLoc - 1))
AllFields = Right(AllFields, Len(AllFields) - CommaLoc)
i = i + 1
Loop
FieldInForm(i) = Trim(AllFields)
TotalFields = i
End Sub
The variable such as FieldInForm(i), CommaLoc will be used outside the Sub routine, except AllFields which just used in Sub-Routine.
2.) Is there a problem if we din't declare the variable used in the sub routine (as above, the total variable).
Confusing......
please advice!