Android Question Do While Loop Puzzle = Solved

Discussion in 'Android Questions' started by Roger Daley, May 30, 2015.

  1. Roger Daley

    Roger Daley Well-Known Member Licensed User

    Error found in reviewing my post. Asking the quest often provides the answer. Smack forehead.

    Hi All,

    I have a problem with a Do Whille Loop. Below is the relevant part of the code, assume the variables are defined.

    The loop always runs through to the MapZoom being zero when it should exit before this. If I include a msgbox in the loop the loop exits at the appropriate level.
    Replacing the msgbox with a Log() doesn't work. Inserting a DoEvents doesn't work. [Clutching at straws]

    There other ways of doing this to by pass the puzzle, but understanding what is going on would be useful.

    Do While (MinX < LeftMin  OR MinY < TopMin) AND MapZoom > 0
            MapZoom = MapZoom - 
            cp.Initialize2(MapLat, MapLng, MapZoom, 
    00 )
            MarkerLocation = BTSMarker.Position
            ScreenPosition = Projection1.toScreenLocation(MarkerLocation)
            BTSX = ScreenPosition.X
            BTSY = ScreenPosition.Y
            MinX = 
            MinY = 
            LeftMin = BTSIV.Width
            TopMin = pnlDispLatLng.Height + LMIV.Height      

    Regards Roger
    Last edited: May 30, 2015
  2. Erel

    Erel Administrator Staff Member Licensed User

    It cannot work. You shouldn't try to hold the main thread in a loop. Instead handle the event sub and do whatever you need when the zoom level is reached.
    Roger Daley likes this.
  3. Roger Daley

    Roger Daley Well-Known Member Licensed User

    Thanks Erel,
    I came to that conclusion. In addition I shouldn't try to do this stuff with a rotten head cold.