Results 1 to 3 of 3

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

  1. #1
    Member
    Join Date
    Mar 12
    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 12
    Location
    West Virginia
    Posts
    4,948

    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 08
    Posts
    6,753

    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.
    The better the information you give to begin with and the sooner you reply the sooner you will get help and get your problem resolved


    When I was young and in my prime I used to program all the time but now I'm old and getting gray I only program once a day

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
  •