Planetarion Forums

Planetarion Forums (https://pirate.planetarion.com/index.php)
-   Programming and Discussion (https://pirate.planetarion.com/forumdisplay.php?f=57)
-   -   VB 6 -Skipping lines of code... (https://pirate.planetarion.com/showthread.php?t=185445)

Howie17 19 May 2005 18:04

VB 6 -Skipping lines of code...
 
Ok so I've been working on this program for quite awhile and recently i've received this error saying "Procedure Is To Long" or something along those lines.. anyway i fixed that by creating a function and then calling that function from the procedure therefore splitting the code into two.. well now, the program runs gets to the function runs through a bit of the code and then skips the rest and goes back to the procedure that called it.

I've checked and double checked to make sure i didn't overlook an "Exit Sub" or something that would tell the program to skip the lines that it is, my only guess is that splitting the code into two chunks and calling the second chunk through a function will apparently not fix the "Procedure is to long" problem. Has anyone ever run into this before? Any guidence would be great. ;)

JetLinus 19 May 2005 19:47

Re: VB 6 -Skipping lines of code...
 
What's the error number?

Never heard of something like this, but it sounds like really really bad code (welcome spaghetti).



Well, splitting the code into multiple parts would exactly be the way to solve this problem. And it should work without skipping code.
You must've done something wrong.

Code?

Howie17 20 May 2005 05:21

Re: VB 6 -Skipping lines of code...
 
There's no error it simply stops in the middle of a function and goes back to the procedure that called it without completing the rest of the code.


form load
-calls cmdSearch

cmdSearch
-Executes quite a few lines of code
-then executes a call ShiftDisplay function

ShiftDisplay
-executes quite a few lines of code but half way through goes back to cmdSearch at the End Sub line




Code:

After this line of code it goes back to the cmdSearch procedure:

Code:

adoShifts.Recordset.MoveFirst
    mintRecordCount = 1
    'Set shifts for each employee based on day of the week.
  Do While Not mintRecordCount = adoShifts.Recordset.RecordCount + 1
       
      If adoShifts.Recordset.Fields(0).Value = cmdEmployee1.Caption Then
                    txtEmployee(mintRecordCount).Left = "960"


It is then followed by multiple ElseIf statments, which i know its suppose to skip. The code that follows the If statement isn't executed.

JetLinus 20 May 2005 10:29

Re: VB 6 -Skipping lines of code...
 
Just out of curiosity:
Quote:

i've received this error saying "Procedure Is To Long"
Do you still remember the error number? I'm just interested in this error, never heard of it...


Concerning your problem: Well. It still doesn't sound really believable.
Did you use Debug.Print or MsgBox to "prove" where the program "jumps out"?
Did you compile an exe and see if the same happens?

I strongly suggest to try "step by step" mode using F8. See what happens then.
No other idea right now, sorry...



(VB6 SP6 is installed?)

Structural Integrity 20 May 2005 10:46

Re: VB 6 -Skipping lines of code...
 
Don't you all just love VB6 ?
What happens if you compile it to machinecode BTW? Does it run fine then? It seems more of a problem with the interpreter than with the code.

I'd define a custom errorhandler for the second function and see if there's no error generated in there (I assume you inherit the first functions errorhandler ATM?).

Howie17 20 May 2005 13:57

Re: VB 6 -Skipping lines of code...
 
Thats not the exact wording of the error but thats what its meaning was.. i'll try to get the error again and let you know the specifics...


Ok, it says:

Quote:

Compile Error:

Procedure too large

Quote:

Concerning your problem: Well. It still doesn't sound really believable.
Did you use Debug.Print or MsgBox to "prove" where the program "jumps out"?
Did you compile an exe and see if the same happens?
-As of yet no I haven't.

Quote:

I strongly suggest to try "step by step" mode using F8. See what happens then.
No other idea right now, sorry...
-This is what i did to determine that it even was skipping code


I took the code out of the function and placed it back in the cmdSearch procedure, I then shortened some of the code in the procedure and it no longer skips the code... so it seems to be something to do with calling a function... idk as long as i can manage the size of the procedure i guess i'll be alright. btw thanks for the help.

JetLinus 20 May 2005 17:38

Re: VB 6 -Skipping lines of code...
 
Quote:

Originally Posted by Structural Integrity
Don't you all just love VB6 ?

Yes I do at least, and you know that ;-)

queball 21 May 2005 01:32

Re: VB 6 -Skipping lines of code...
 
Did you call End Sub instead of End Function?

(It might have to be Exit Sub instead of Exit Function - I'm not hot on VB syntax.)

JetLinus 21 May 2005 11:29

Re: VB 6 -Skipping lines of code...
 
Quote:

Originally Posted by queball
Did you call End Sub instead of End Function?

(It might have to be Exit Sub instead of Exit Function - I'm not hot on VB syntax.)

Usually VB fixes that by auto-correction. If not, then it should give a compiler error...

Caesar2 21 May 2005 14:44

Re: VB 6 -Skipping lines of code...
 
Quote:

Originally Posted by http://msdn.microsoft.com/
Procedure too large
Specifics

When compiled, the code for a procedure can't exceed 64K. This error has the following cause and solution:

Code for this procedure exceeds 64K when compiled.
Break this, and any other large procedures, into two or more smaller procedures.

Found here

Howie17 21 May 2005 21:42

Re: VB 6 -Skipping lines of code...
 
thanks for the lookup Caesar2. I figured that would fix it which it did... but now its confusing me to why its skipping lines of code, which i've bypassed by shortening the orignal procedure and keeping everything together... we'll see if i can get by with keeping the procedure within 64kb..

Structural Integrity 22 May 2005 01:22

Re: VB 6 -Skipping lines of code...
 
Quote:

Originally Posted by Caesar2

Typical...
"Hey... let's statically allocate memory for procedures... 64k should do it."

I get the shivers when I see stuff like that. It once took me two days to hunt down a bug that crashed the IDE because someone decided it'd be cool to have a statically allocated array filled by a function in a DLL, and then go over the bounds.
Particularly cool when you don't have the code of the DLL, and don't even have an idea what the fk it does.

Well, atleast these guys were nice enough to generate an error instead of just letting it crash and burn.

Demon Dave 22 May 2005 01:41

Re: VB 6 -Skipping lines of code...
 
for some strange reason known only to himeself, my college admin has decided to block all microsoft websites. even msdn :(

Epcylon 23 May 2005 21:19

Re: VB 6 -Skipping lines of code...
 
Sounds like a sensible sysadmin tbh.. ;)

Raging.Retard 23 May 2005 22:42

Re: VB 6 -Skipping lines of code...
 
This begs the question, why do you have (or need) a single procedure thats 64k in length?

JetLinus 24 May 2005 04:51

Re: VB 6 -Skipping lines of code...
 
Because he needs some lines of code to executed a couple of hundred times?

[/badjoke] :-/


All times are GMT +1. The time now is 11:46.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2002 - 2018