KenHigg
Registered User
- Local time
- Today, 08:36
- Joined
- Jun 9, 2004
- Messages
- 13,327
Like I said, it goes beyond the example we are working with. If you get in the habit of breaking down the code into logical pieces when doing simple routines, when you have to write more complex routines the methodology comes more natural.
For example, if you had three conditions you need to meet before you execute the primary part of the routine, using your method you could have something like:
This is like spaghetti code to me and gets real hard to follow real fast. This is much easier for me to follow:
For example, if you had three conditions you need to meet before you execute the primary part of the routine, using your method you could have something like:
Code:
if condition 1 is true then
if condition 2 is true then
if condition 3 is true then
Do the prmary part of your logic
else
Warn the user condition 3 was not met
end if
else
Warn the user condition 2 was not met
end if
else
Warn the user condition 1 was not met
end if
This is like spaghetti code to me and gets real hard to follow real fast. This is much easier for me to follow:
Code:
'Testing section---------------
if condition 1 is false then
Warn the user condition 1 was not met
exit sub
end if
if condition 2 is false then
Warn the user condition 2 was not met
exit sub
end if
if condition 3 is false then
Warn the user condition 3 was not met
exit sub
end if
'Logic section---------------
Do the prmary part of your logic