Upgrade error: 'Goto xxx' is is not valid because 'xxx' is inside a 'For' or '
Hi guys,
i'm upgrading some big chunks of vb6 codes into .NET and I'm getting a few
errors like this one below:
Error 40 'GoTo xxx' is not valid because 'xxx' is inside a 'For' or 'For Each' statement that does not contain this statement.
Now, I know that it's bad practice to use Goto in the first place(spaghetti all over)..but I got the code as it is. i didn't write it. i just try to upgrade it and get it to work..
I think one solution to use a Sub/function to do this.?
Problem is there are some hundreds of lines of code under 'xxx' and I think there are many variables to take care of.
I'm just wondering, whether there's a way maybe by replacing 'For' loop with 'Do while ' that'll get rid of this error?? please let me know
Thanks.
Re: Upgrade error: 'Goto xxx' is is not valid because 'xxx' is inside a 'For' or '
Hard to say without seeing the related code. Show us what you are talking about then maybe we can help.
Note: Just paste the related section of code and use code tags around it to preserve formatting.
Re: Upgrade error: 'Goto xxx' is is not valid because 'xxx' is inside a 'For' or '
Quote:
Originally Posted by
SandiegoSSD
Error 40 'GoTo xxx' is not valid because 'xxx' is inside a 'For' or 'For Each' statement that does not contain this statement.
Well it tells you that the label xxx does not exist within the loop so put one in the loop - where? I don't have any idea without seeing your code problem. Jumping into the middle of a loop is not a good idea and I can't think of any reason why one would need to do so. Rewriting the loop would be the better way to go if you can't do without the loop