|
-
Jun 3rd, 2019, 06:03 AM
#1
Thread Starter
New Member
Using timers to action next set of code
Evening All,
Just need some advice on using a timer to automatically action the next set of code, once the time reaches a particular time. I was considering using a DO WHILE or DO UNTIL but just can't get it to work
textbox4 allows to see the steps counting up which is great. As soon as I add the DO WHILE/UNTIL it stops counting. Below is my code, which is used to move stepper motors.
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
TextBox4.Text = TextBox4.Text + 1
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim BoardNumber As Integer
Dim Steps As Integer
Dim Interval As Integer
Dim Direction As Integer
Dim Inputs As Integer
Dim Outputs As Integer
Dim Err As Integer
Dim Result As Integer
Dim M1Mode As Integer
Dim M2Mode As Integer
Dim M1StepsLeft As Integer
Dim M2Stepsleft As Integer
Static count As Integer
Dim skip As Integer
skip = TextBox3.Text
count = count + 1
Result = count + skip
TextBox2.Text = Result
If Result = 3 Then
Timer1.Interval = 100
Timer1.Start()
BoardNumber = 1
Steps = 200
Interval = 100
Direction = 0
Err = CM_Stepper_RunMotor2(BoardNumber, Steps, Interval, Direction, Outputs)
Do Until TextBox4.Text >= 100
Loop
TextBox1.Text = "it worked"
End If
End Sub
End If
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|