Problem with the line

Hi,
I don't know why I have got the error (Shown in Fig 1)

to the last line below?
Sub Validate_repre_code(msg As String, para_code As String, para_fnd As Boolean)
    Dim local_rw As Integer
    
    ...
End Sub
        
    Dim fnd_repre As Boolean, repre_code As String, chk_msg As String
    ...
                repre_code = Cells(rw_kp + 1, 11).Value
                chk_msg = ""
                Validate_repre_code chk_msg, repre_code, fnd_repre
                ...

Open in new window


The previous codes are working fine, while I've just added the above codes to the existing ones. Once I've remarked the above line in error, the whole process again is working fine. Why?
t510.png
LVL 12
HuaMin ChenProblem resolverAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
have tested the code snippet as you posted it, and it works just fine.

the only reason I know you will get this error is when chk_msg is NOT defined as string.

please make sure you don't have that variable DIMed somewhere else with other data type.
0
HuaMin ChenProblem resolverAuthor Commented:
Thanks.
Within the whole process, chk_msg is NOT DIMed elsewhere.
0
Guy Hengel [angelIII / a3]Billing EngineerCommented:
how big is the project / makro?
the only other explanation is that you are missing a project reference...
or that the 2 lines
chk_msg = ""
                Validate_repre_code chk_msg, repre_code, fnd_repre

Open in new window

are before the line which dim's the chk_msg.
do you have OPTION EXPLICIT on the first line of the code ?
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

HuaMin ChenProblem resolverAuthor Commented:
Yes, it is VBA macro.

chk_msg has been DIMed before these 2 lines.

chk_msg = ""
                Validate_repre_code chk_msg, repre_code, fnd_repre

Open in new window


I don't have OPTION EXPLICIT in the whole macro.
0
Guy Hengel [angelIII / a3]Billing EngineerCommented:
>I don't have OPTION EXPLICIT in the whole macro.
please add that line as first line in the marco, and run the compile.

did you check the project => references?

otherwise, can you attach the project file with "reduced" code but still with the issue?
0
HuaMin ChenProblem resolverAuthor Commented:
After I've put the line like (shown in Fig 2)

I get the current error shown in Fig 2. Why?
t513.png
0
Guy Hengel [angelIII / a3]Billing EngineerCommented:
first line of the MAKRO, no of the procedure/sub.
it has to be the TOP LINE of your code page
0
HuaMin ChenProblem resolverAuthor Commented:
But now I get this (shown in Fig 3), while I've DIMed the variable already.
t515.png
0
HuaMin ChenProblem resolverAuthor Commented:
Please help. thanks
0
Guy Hengel [angelIII / a3]Billing EngineerCommented:
this error is self-explaining.
you don't declare that variable anywhere ...
0
TommySzalapskiCommented:
The Option Explicit that you added is going to make you go back and Dim every variable that you haven't.
Expect several of those errors, but when you get them all cleaned up, you may just find the original issue and solve it.
0
HuaMin ChenProblem resolverAuthor Commented:
Sorry, after having put that, I am still getting the same problem
t516.png
0
Guy Hengel [angelIII / a3]Billing EngineerCommented:
please upload the file.
otherwise I cannot "see" deeper
0
HuaMin ChenProblem resolverAuthor Commented:
Thanks. I did change the way to not to pass any string to a subroutine. Then it works as expected.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
HuaMin ChenProblem resolverAuthor Commented:
I resolved this already
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows OS

From novice to tech pro — start learning today.