I did not post code because project is 13,000 lines. I see that I also have some undeclared variables and a warning: Return type (in Sub signature) should be set explicitly, However I was surprised when it compiles and runs fine with DoEvents but not with Sleep(0). I have used DoEvents in code many times (100+). The first part of code in sub with error is:
Sub Filter_Overlay_Touch(Action As Int, X As Float,Y As Float)
'Msgbox("overlay",Y)
X=X/WS: Y=Y/HS
'Msgbox(X,Y)
Dim Z,ZZ As String
Dim V As Float
Dim PR As String
Select Action
Case Activity.ACTION_DOWN
Z=File.ReadString(File.DirRootExternal,"/JVJ/download/stocktmp")
J=1: 'pointer to first entry in list
H=0: V=0
'CC=Z.Length*.05: '5%
ZZ=""
If X<150 And Y>210 And Y<270 Then
'from price
PriceRangeList.Visible=True
Return True
Else If X<150 And Y>300 And Y<360 Then
'to price
PriceRangeList2.Visible=True
Return True
Else If X<150 And Y>100 And Y<175 Then
'reset
Filter_Overlay.SetBackgroundImage(LoadBitmap(File.DirRootExternal, "/JVJ/images/page/wait.jpg"))
DoEvents
If Instr(SUMMARY.Text&" ","CLEARANCE ITEMS:")>0 Then
Z=File.ReadString(File.DirRootExternal,"/JVJ/download/clear")
tabs(1).Tag="CLEARANCE ITEMS:"
Else
Z=File.ReadString(File.DirRootExternal,"/JVJ/download/stock")
tabs(1).Tag="INVENTORY ITEMS:"
End If
plus many more else if statements.
I wanted to use Return True to exit Sub so code below if statement would not run.