Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

qn on standard modules...

Hi Guys,

Can someone explain to me how exactly to use a standard module (.bas)? I have encountered some problems recently where i tried to create some modules in my application.
The algo works fine when everything is under the form code editor. But when I created the modules, I encountered a compiled error when i call the function from the main form.

The error states:- Expected variable or procedure, not module
When i remove the Call, the error becomes:- Expected: =

I don't encounter this problem when i am passing in 1 value and it happens only when i try to pass in more than 1 value into a sub or function. :confused:

The Call from the main:
Private Sub Option1_Click()
intOpTempNum = 1
Call LUTSelector(intOpTempNum, strLUTName)
End Sub
My module:
Public Function LUTSelector(ByVal intTempOpTempNum As Integer, ByVal strTempLUTName As String)

Select Case intTempOpTempNum
Case 1
Select Case strTempLUTName
.....

Actually i think i need a sub rather than a function because i dun need it to return any value. This program selects the LUT according to the options checked, and it is done by using Select-Case method.

Other qn:
Why do we sometimes use ByVal and sometimes not when we are passing avlues from the main to a function or sub?

When can we use the Call method? When we are calling for function?
[1476 byte] By [ootnitsuj] at [2007-11-11 8:27:05]
# 1 Re: qn on standard modules...
I think it is because you have "intOpTempNum" in your click event and "intTempOpTempNum" in your module. Since the two don't match there really isn't a value passing. I started using small, easy variables to cut back on typing time and mistakes.
Hope this helps, Garner
Garner at 2007-11-11 17:25:33 >
# 2 Re: qn on standard modules...
Hi Garner,

Thanks for your advice

I thinkit does not matter what variabe name i have (intOpTempNum) in my calling statement because as a matter of fact, that is what i am going to pass into the function that will take in a value which will be assigned to intTempOpTempNum. This variable intTempOpTempNum will then be used in the function called (LUTSelector).

Hope that I am right... :D
ootnitsuj at 2007-11-11 17:26:33 >