|
-
Mar 25th, 2002, 01:17 PM
#1
Thread Starter
Lively Member
Need help with GoTo labels!
I was just wondering if there was a way to return back to where i left off after going to a label. ex-
if Blah=True then Goto LABEL_BLAH
LABEL_BLAH:
do some stuff
Return to line right after the if/then statement
Often talked of, never seen,
Ever coming, never been,
Daily looked for, never here,
Still approaching, coming near,
Thousands for its visit wait,
But alas for their fate,
Tho' they expect me to appear,
They will never find me here.
What's this about?
-
Mar 25th, 2002, 01:35 PM
#2
Use a function, or Subroutine. There is now ay to go back to where you started from using GoTo.
Z.
-
Mar 25th, 2002, 01:35 PM
#3
And you should NEVER use gotos anyway.
Z.
-
Mar 25th, 2002, 01:39 PM
#4
Thread Starter
Lively Member
thnx for the help.
I was just wondering since the goto is already in a function and i thought it seemed kinda odd to make a seperate function or sub just for my 3 or 4 lines of code, but OK.
Often talked of, never seen,
Ever coming, never been,
Daily looked for, never here,
Still approaching, coming near,
Thousands for its visit wait,
But alas for their fate,
Tho' they expect me to appear,
They will never find me here.
What's this about?
-
Mar 25th, 2002, 02:14 PM
#5
Hyperactive Member
Re: Need help with GoTo labels!
Originally posted by Killerguppy101
I was just wondering if there was a way to return back to where i left off after going to a label. ex-
if Blah=True then Goto LABEL_BLAH
LABEL_BLAH:
do some stuff
Return to line right after the if/then statement
Can you not just use an On Blah Goto Whatever Resume Next like you do with errors?
Code:
on error goto exiterror resume next
do whatever
exiterror:
do whatever
-
Mar 25th, 2002, 02:25 PM
#6
Dont have errors in your program =).
Z.
-
Mar 25th, 2002, 03:24 PM
#7
transcendental analytic
Zaei, theres difference between exception handling and errors in the program as in bugs.
Killerguppy101, this is probably what you are looking for, Gosubs are lighter than function calls, but they are messy, so be cautious.
Code:
Dim a
GoSub 20
MsgBox a
Exit Sub
20:
a = 10
Return
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Mar 25th, 2002, 03:27 PM
#8
I know, but its no excuse =).
Z.
-
Mar 25th, 2002, 03:28 PM
#9
You could try
VB Code:
If Blah=True Then Goto LABEL_BLAH
LABEL_BLAH:
'do some stuff
Resume Next
End If
Although, with the exception of On Error GoTo, I would agree with Zaei, and never use GoTos.
-
Mar 25th, 2002, 03:29 PM
#10
Hyperactive Member
Actually I wasn't talking about errors. I just wondered whether exception handling could be used for anything else besides errors.
-
Mar 25th, 2002, 04:07 PM
#11
transcendental analytic
In C++ or Java you can use exception handling for almost anything that has to do with selectional execution (many people do, and many people also argue against it) but many times exception handling has nothing to do with errors at all.
Goto is not nessesary evil, its just lowlevel, and vb programmers shouldn't be accustomed to such, they should be planting pictureboxes and handling events
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Mar 25th, 2002, 06:52 PM
#12
Frenzied Member
Yeah that's one of the things that I don't agree about VB.NET, they basically removed all the low-level stuff that we used to optimize our programs
-
Mar 26th, 2002, 12:51 AM
#13
You can do some odd things with SEH:
Code:
int func(int x) {
_try { // I think its one underscore, though it may be two...
return x;
}
_finally { // again, I think its one, but it may be two...
x+=1;
}
}
...
x = func(2)
Guess what x is. Its 3, because the _finally block is executed before x is returned.
Z.
-
Mar 26th, 2002, 03:37 AM
#14
transcendental analytic
two underscores 
well, you have to see this one, because at first sight it looks like spaghetti code 
Code:
#include "stdio.h"
void main()
{
int* p = 0x00000000; // pointer to NULL
puts("hello");
__try{
puts("in try");
__try{
puts("in try");
*p = 13; // causes an access violation exception;
}__finally{
puts("in finally");
}
}__except(puts("in filter"), 1){
puts("in except");
}
puts("world");
}
hello
in try
in try
in filter
in finally
in except
world
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
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
|