Results 1 to 7 of 7

Thread: I need help... please help...

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2006
    Posts
    389

    I need help... please help...

    ok here is my code...

    VB Code:
    1. For i = 1 To 138
    2.     Set ini = New Class1
    3.         With ini
    4.         .File = App.Path & "\worlds.ini"
    5.         location = .GetValue("World" & i, "Location")
    6.         types = .GetValue("World" & i, "Type")
    7.         flag = .GetValue("World" & i, "Flag")
    8.         If types = "Members" Then
    9.        
    10.         End If
    11.         Set list_item = listview1.ListItems.Add(, , location)
    12.             list_item.SubItems(1) = i
    13.             list_item.SubItems(2) = Server_Players(i, strhtml)
    14.              list_item.SubItems(3) = types
    15.     End With
    16.     Next i

    and I need to make it go to the next i under this:
    VB Code:
    1. If types = "Members" Then

    and I cant use a
    VB Code:
    1. next i
    there because you cant do that... so how do I do this?
    Visual Basic Rules!!!!!

  2. #2
    Hyperactive Member half flung pie's Avatar
    Join Date
    Jun 2005
    Location
    South Carolina, USA
    Posts
    317

    Re: I need help... please help...

    maybe something like this would work?
    VB Code:
    1. For i = 1 To 138
    2. Whatever:
    3.     Set ini = New Class1
    4.         With ini
    5.         .File = App.Path & "\worlds.ini"
    6.         location = .GetValue("World" & i, "Location")
    7.         types = .GetValue("World" & i, "Type")
    8.         flag = .GetValue("World" & i, "Flag")
    9.         If types = "Members" Then
    10.           i = i+1
    11.           goto Whatever        
    12.         End If
    13.         Set list_item = listview1.ListItems.Add(, , location)
    14.             list_item.SubItems(1) = i
    15.             list_item.SubItems(2) = Server_Players(i, strhtml)
    16.              list_item.SubItems(3) = types
    17.     End With
    18.     Next i

    Base 2
    Fcnncu"Nqxgu"Lguug##

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    May 2006
    Posts
    389

    Re: I need help... please help...

    yea that worked great thanks... if anyone else has another way then let me know...
    Visual Basic Rules!!!!!

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: I need help... please help...

    How about
    VB Code:
    1. For i = 1 To 138
    2.     Set ini = New Class1
    3.         With ini
    4.         .File = App.Path & "\worlds.ini"
    5.         location = .GetValue("World" & i, "Location")
    6.         types = .GetValue("World" & i, "Type")
    7.         flag = .GetValue("World" & i, "Flag")
    8.         If types <> "Members" Then        
    9.             Set list_item = listview1.ListItems.Add(, , location)
    10.             list_item.SubItems(1) = i
    11.             list_item.SubItems(2) = Server_Players(i, strhtml)
    12.              list_item.SubItems(3) = types
    13.        End If
    14.        End With
    15. Next i

  5. #5
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: I need help... please help...

    Just make the loop pass once if type is not "Members"

    If types <> "Members" Then Exit For

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: I need help... please help...

    Quote Originally Posted by leinad31
    Just make the loop pass once if type is not "Members"

    If types <> "Members" Then Exit For
    If you Exit the For/Next there is the possibility of some records not being processed depending on when it does hit "Members"

  7. #7
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: I need help... please help...

    @half flung pie

    NEVER manipulate a loop counter from within the loop. there's no guarantee that, in some future version, or in some other language, the loop counter variable is actually checked every iteration. Some compilers generate code that keeps a local copy of the "variable" - sort of like passing a variable to a sub ByVal - so nothing you do to the counter variable will change the execution of the code. (Other compilers produce code that will crash if you make the loop counter larger than the 'To' value in order to exit the loop prematurely.)
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

Posting Permissions

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



Click Here to Expand Forum to Full Width