Link to home
Start Free TrialLog in
Avatar of testing38
testing38

asked on

Speed: Need more!

I have a quite large loop in my program and want to increase the speed at which it runs... Is there any way to do this? The code is below. Although you might want to copy it into wordpad... It may be hard to read otherwise. All varables are delcared as best and small as they could be. Thanks!


For xnow = 0 To XMAPSHOWN * (tile_width + 2) Step tile_width
tilex = tilex + 1
tiley = ycord
For ynow = 0 To ymapshown * (tile_Height + 2) Step tile_Height
tilenow = map(tilex, tiley).land1

If tilenow < 1000 Then GoTo no_draw
If tilenow >= 1000 And tilenow <= 1225 Then page = 1
If tilenow >= 2000 And tilenow <= 2225 Then page = 2
If tilenow >= 3000 And tilenow <= 3225 Then page = 3
If tilenow >= 4000 And tilenow <= 4225 Then page = 4
If tilenow >= 5000 And tilenow <= 5225 Then page = 5
If tilenow >= 6000 And tilenow <= 6225 Then page = 6
If tilenow >= 7000 And tilenow <= 7225 Then page = 7
If tilenow >= 8000 And tilenow <= 8225 Then page = 8
If tilenow >= 9000 And tilenow <= 9225 Then page = 9

tile = (tilenow - (page * 1000)) - 1
i = BitBlt(mapeditor.Picture1.hdc, xnow, ynow, tile_width, tile_Height, Graphics.Graphics_pages(page + 9).hdc, ((tile Mod temtiles_ud) * (tile_width + 2)) + 1, ((tile \ temtiles_rl) * (tile_Height + 2)) + 1, SRCAND)
i = BitBlt(mapeditor.Picture1.hdc, xnow, ynow, tile_width, tile_Height, Graphics.Graphics_pages(page).hdc, ((tile Mod temtiles_ud) * (tile_width + 2)) + 1, ((tile \ temtiles_rl) * (tile_Height + 2)) + 1, SRCINVERT)
no_draw:

tiley = tiley + 1
Next ynow
Next xnow
Exit Sub
ASKER CERTIFIED SOLUTION
Avatar of scrapdog
scrapdog
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of testing38
testing38

ASKER

Thanks this worked great with a little editing!
Just another thought you may find useful - on your iterative "next", comment out (but leave it for readability) the counter name ie Next 'ynow (comment) and Next 'xnow(comment) - this will improve the speed considerable, expecially since there are two nested loops running. Simple but effective.