Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code is skipping a Line

Status
Not open for further replies.

RickyRicardo

Programmer
Jun 25, 2002
12
CA
I have a large function that runs. It takes time to run so I have a progress bar in it. I am trying to make a label become visible in the Top of the function, but it skips that line. How do i fix this error?

Ricky
 
Ricky,

The code doesn't skip a line unless you tell it to using a GOTO, you have 'On Error Resume Next' and have an error on the line, or the code control causes jumps around the code and you can't determine where it is going.

Try debugging the code you have. Set a breakpoint {F9} on the code prior to the line that sets the label to visible. Press F8 to take a single code step and examine all variables to see whether their values are what you had intended. This is expecially important if you are using ifs to control the code flow. You can view the value of the variables by moving the cursor over the top of the variable and let Intellisense show you what the value is or you can type ?VariableName in the immediate window and have it return the value of the variable.

----------------------
scking@arinc.com
Life is filled with lessons.
We are responsible for the
results of the quizzes.
-----------------------
 
Generally, when it's running a long process, it has a hard time putting something on top. Just add DoEvents immediately after that line. That's fixed the problem for me in the past.
 
Reply to email
Computers don't just decide they don't like a line of code, there will be a reason why it's not doing what you think it should. Have you tried moving through the code a line at a time? Type stop at the start of the procedure that is causing the problems. The code will run until it hits stop then switch to code view with the stop line highlighted in yellow. press f8 to go through a line at a time to see what your program is doing.

Hope this solves things.

B
----------------------------------
Ben O'Hara
Home: bpo@RobotParade.co.uk
Work: bo104@westyorkshire.pnn.police.uk
Web: ----------------------------------
 
Hi,

I have debugged it many times by placing a breakpoint at where the lable becomes visible and by stepping through it. Everytime I debug the code the label becomes visible, but if I do not debug the code, the line is skipped. There are no On Error Resume Next or GOTOs, but I added the DoEvents line, like TojanRabbit said, right after making the label visible and it seems to work. Thanks for the help.

Ricky
 
Try putting me.repaint after enabling the label. Might help.

B ----------------------------------
Ben O'Hara
Home: bpo@RobotParade.co.uk
Work: bo104@westyorkshire.pnn.police.uk
Web: ----------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top