|
-
May 9th, 2006, 04:27 PM
#1
Thread Starter
Lively Member
So...why not?
People always tell me never to use Goto statements in my code, but nobody has ever really given me a valid reason why not. Its always sort of been a "because I said so" argument. In fact one guy I know told me that his professor in college said if any code contained a goto, he would fail the student on the spot.
So, whats the real reason this is such a no-no? I've written stuff that programmers in this company have been trying to accomplish for years...and I do most of it with the right combination of If/Then statements & Goto's. When working with spreadsheets, a goto statement lets me perform the same chunk of code over & over on every line of the spreadsheet whether it be 5 or 5000 rows, and as long as the statement ends with (A = A + 1, if wkst.cells(A,1) <> "" then Goto START:,) it works like a charm...I never have to worry about a predefined number of variables, it adapts itself to whatever source data I'm working with, and the code runs as fast as whatever system I'm working in...if all the functions it performs take place in an excel spreadsheet, it can complete a full spreadsheet of 1000+ rows in under a second and has never caused an error for me.
So, what disadvantages are there to a goto statement really? Sorry if its a dumb question, but the only way I can improve my coding is by asking questions...even the dumb ones.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|