Private Function calculate() cx = (X - x1) * xratio cy = (Y - y1) * yratio If cx < 0 Then xd = 0 cx = (0 - cx) Else xd = 1 End If If cy < 0 Then yd = 2 cy = (0 - cy) Else yd = 3 End If cx = CInt(cx) cy = CInt(cy) If cx = 0 Then xr = 0 yr = 1 ElseIf cy = 0 Then yr = 0 xr = 1 Else crflag = 1 If cx < cy Then cr = cx / cy Else cr = cy / cx End If For cri = 1 To range crtemp = (cr * cri) crtemp = CInt(crtemp) - crtemp crtemp = Format(crtemp, "####0.00000") If crtemp < 0 Then crtemp = 0 - crtemp End If If crflag = 1 Then crlow = crtemp crlowi = cri crflag = 0 Else If crtemp < crlow Then crlow = crtemp crlowi = cri End If End If Next cri If cx < cy Then xr = crlowi yr = CInt(crlowi / cr) Else yr = crlowi xr = CInt(crlowi / cr) End If For cri = range To 1 Step -1 If (xr Mod cri) = 0 And (yr Mod cri) = 0 Then xr = xr / cri yr = yr / cri End If Next cri tempr = xr xr = yr yr = tempr End If xr1 = xr Mod 10 xr = (xr - xr1) / 10 xr2 = xr Mod 10 xr = (xr - xr2) / 10 xr3 = xr Mod 10 xr = (xr - xr3) / 10 xr4 = xr Mod 10 yr1 = yr Mod 10 yr = (yr - yr1) / 10 yr2 = yr Mod 10 yr = (yr - yr2) / 10 yr3 = yr Mod 10 yr = (yr - yr3) / 10 yr4 = yr Mod 10 cx1 = cx Mod 10 cx = (cx - cx1) / 10 cx2 = cx Mod 10 cx = (cx - cx2) / 10 cx3 = cx Mod 10 cy1 = cy Mod 10 cy = (cy - cy1) / 10 cy2 = cy Mod 10 cy = (cy - cy2) / 10 cy3 = cy Mod 10 cy = (cy - cy3) / 10 cy4 = cy Mod 10 End Function

i am using this function in my program..its being called repeatedly(more than 200-300 times)..initially,it takes no delay for execution..bt as it proceeds, the time taken for executing the function is becoming higher..this slows down my software..how can i solve it???

This post has been edited by **BobRodes**: 24 April 2012 - 11:41 AM

Reason for edit:: code tags