dcsimg
Results 1 to 3 of 3

Thread: Upgrade error: 'Goto xxx' is is not valid because 'xxx' is inside a 'For' or '

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2012
    Posts
    49

    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.

  2. #2
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    13,088

    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.

  3. #3
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Upgrade error: 'Goto xxx' is is not valid because 'xxx' is inside a 'For' or '

    Quote Originally Posted by SandiegoSSD View Post

    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
    Last edited by jmsrickland; Jun 19th, 2012 at 01:18 PM.


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width