to stop a sub in the middle waiting for a button_click

  • Thread starter Thread starter andreas
  • Start date Start date
A

andreas

Hi,
Is it possible to stop a sub in the middle waiting for a button clic to go
further ?
F.e.

dim blnToStop as boolean

private sub test
.......
.......
if blnTostop then
........? ' ( a button to click )
end if
..........
.......
end sub

Thanks for any response
 
* "andreas said:
Is it possible to stop a sub in the middle waiting for a button clic to go
further ?
F.e.

dim blnToStop as boolean

private sub test
......
......
if blnTostop then
.......? ' ( a button to click )
end if
.........
......
end sub

Basically no. Why don't you call the 2nd part from your button's
'Click' event handler?
 
Hi try this
it one way to do it
=====================
Dim Xclick As Int16 = 0
Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load
test()
End Sub

Private Sub test()
If Xclick = 1 Then Exit Sub
If Xclick = 2 Then GoTo continue
Xclick = 1 ' make count 1 so it only runs the "beginig code" once
MsgBox("start")
Exit Sub
continue:
MsgBox("end ")
Xclick = 0 ' reste the counter
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
If Xclick = 1 Then ' make sure that the first part is done
Xclick = 2 ' run the rest of the code :)
test() ' call the sub agin
End If
End Sub


=======================
/Jens
 
Hi Andread,

I think yes very easy.

Make a loop something like this with a global boolean myStop
Roughly typed

While myStop
threading.thread.sleep(1000)
application.doevents
loop

Click event from button
myStop = false

I hope this works?

Cor
 
Back
Top