Public variable problem
The error message is not "ambiguous name". May be Object not set. Now,
my problem seem working ok.
In each module, I have 3 steps
1. Base on raw data file, build Account mapping
2. Build Summary base on raw data file
3. Build Upload text file, upload to ERP system
If run step 1 ,step 2 and then step 3 without error run under same
module(e.g. JAP)
Then ,select other module (eg.Singapore) may have error.
I just want define below two lines as public variable
Public gerr_Cnt As Long
Public gShErr As Worksheet
Also, how to using Interface/Implements in classes module ?
NickHK wrote:
What you are trying will error, with "ambiguous name".
Public variables in modules are global to the project, so you cannot
duplicate names.
If they are different variables, give them different name.
Otherwise just declare in one module as public and they will be available to
all modules.
Depending on your structure, could you expose them through the class for
each location ?
NickHK
As a side-line, depending on the similarity of your different location
classes, would using an Interface/Implements be better ?
Then you may only need a single module, because you can :
'Declare the object as the Interface
Dim MyLocation As ILocation
'Set the object to the required class, as each Implements ILocation
Private Sub CommandButton1_Click()
Select Case UCase(InputBox("First letter of the location."))
Case "J"
Set MyLocation = New CJapan
Case "S"
Set MyLocation = New CSingapore
Case Else
Set MyLocation = Nothing
MsgBox "Invalid"
End Select
If Not MyLocation Is Nothing Then MyLocation.Step1
End Sub
"moonhk" wrote in message
ups.com...
I have nine module 1 to module 9. Each module handle one location of
Voucher.
How to define following two public variable ? Need to define in each
module ?
Public gerr_Cnt As Long
Public gShErr As Worksheet
Module 1
Option Explicit
'~~ 2006/11/24
Public gcJap As New clsConfigJap
Public gerr_Cnt As Long
Public gShErr As Worksheet
Sub Voucher_JAP_Step_1()
....
end
Module 2
Option Explicit
Public gcSin As New clsConfigSin
Public gerr_Cnt As Long
Public gShErr As Worksheet
Sub Voucher_SIN_Step_1()
....
end
|