From: Phillip Holmes on 22 May 2010 21:28 Referring to the original query, I did it this way, which I think allows the process to create and run on its own thread which will avoid your PC from locking up during the operation. Regards, Phil. Public Class Form1 Private Const ROTATE_NONE = 0 Private Const ROTATE_CLOCKWISE = 1 Private Const ROTATE_COUNTERCLOCKWISE = 2 Private WithEvents m_objTimer1 As New System.Timers.Timer() Private m_intDirection As Integer Private m_intPorta As Integer Private m_intPortc As Integer Private m_intRotcw(4), m_intRotccw(4) As Integer Private m_intData(8) As Integer Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Initialize Dim a As Integer m_objTimer1.Interval = 1000 '1 Second m_intPorta = &H378 m_intPortc = m_intPorta + 2 m_intData(1) = 153 m_intData(2) = 150 m_intData(3) = 102 m_intData(4) = 105 m_intData(5) = 102 m_intData(6) = 150 m_intData(7) = 153 m_intData(8) = 105 For a = 1 To 4 m_intRotcw(a) = m_intData(a) Next For a = 1 To 4 m_intRotccw(a) = m_intData(a) Next End Sub Private Sub btnClockwise_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClockwise.Click m_intDirection = ROTATE_CLOCKWISE m_objTimer1.Start() End Sub Private Sub btnCClockwise_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCClockwise.Click m_intDirection = ROTATE_COUNTERCLOCKWISE m_objTimer1.Start() End Sub Private Sub m_objTimer1_Elapsed(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs) Handles m_objTimer1.Elapsed Dim iResult As Integer = 0 Select Case m_intDirection Case ROTATE_NONE iResult = 1 'Not doing anything so stop the timer, but should not happen Case ROTATE_CLOCKWISE iResult = RotateClockwise() Case ROTATE_COUNTERCLOCKWISE iResult = RotateCounterClockwise() End Select If iResult = 1 Then 'Stop the timer m_objTimer1.Stop() End If End Sub Private Function RotateClockwise() As Integer Dim iRet As Integer = 0 Static a As Integer = 1 Static b As Integer = 1 If a = 1 And b = 1 Then 'Initialize rotation Out(m_intPorta, 105) Out(m_intPortc, 11) End If Out(m_intPorta, m_intRotcw(b)) Out(m_intPortc, 11) Out(m_intPortc, 10) b = b + 1 If b > 4 Then b = 1 a = a + 1 End If If a = 13 And b = 1 Then 'End rotation Out(m_intPorta, 0) Out(m_intPortc, 11) Out(m_intPortc, 10) 'Reset counters a = 1 iRet = 1 'To let calling function know that rotation is complete End If Return iRet End Function Private Function RotateCounterClockwise() As Integer Dim iRet As Integer = 0 Static a As Integer = 1 Static b As Integer = 1 If a = 1 And b = 1 Then 'Initialize rotation Out(m_intPorta, 105) Out(m_intPortc, 11) End If Out(m_intPorta, m_intRotcw(b)) Out(m_intPortc, 11) Out(m_intPortc, 10) b = b + 1 If b > 4 Then b = 1 a = a + 1 End If If a = 13 And b = 1 Then 'End rotation Out(m_intPorta, 0) Out(m_intPortc, 11) Out(m_intPortc, 10) 'Reset counters a = 1 iRet = 1 'To let calling function know that rotation is complete End If Return iRet End Function Private Sub Out(ByVal int1 As Integer, ByVal int2 As Integer) 'Dummy sub to avoid commenting out the 'Out' code bits End Sub End Class *** Sent via Developersdex http://www.developersdex.com ***
From: C. Kevin Provance on 22 May 2010 21:44 No .Nxt code here. You got the wrong forum pal. -- Customer Hatred Knows No Bounds at MSFT Free usenet access at http://www.eternal-september.org ClassicVB Users Regroup! comp.lang.basic.visual.misc "Phillip Holmes" <phillipholmes1(a)btinternet.com> wrote in message news:OiCGSdh%23KHA.4316(a)TK2MSFTNGP04.phx.gbl... : Referring to the original query, I did it this way, which I think allows : the process to create and run on its own thread which will avoid your PC : from locking up during the operation. Regards, Phil. : : Public Class Form1 : Private Const ROTATE_NONE = 0 : Private Const ROTATE_CLOCKWISE = 1 : Private Const ROTATE_COUNTERCLOCKWISE = 2 : : Private WithEvents m_objTimer1 As New System.Timers.Timer() : : Private m_intDirection As Integer : Private m_intPorta As Integer : Private m_intPortc As Integer : Private m_intRotcw(4), m_intRotccw(4) As Integer : Private m_intData(8) As Integer : : Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As : System.EventArgs) Handles MyBase.Load : 'Initialize : Dim a As Integer : : m_objTimer1.Interval = 1000 '1 Second : : m_intPorta = &H378 : m_intPortc = m_intPorta + 2 : : m_intData(1) = 153 : m_intData(2) = 150 : m_intData(3) = 102 : m_intData(4) = 105 : m_intData(5) = 102 : m_intData(6) = 150 : m_intData(7) = 153 : m_intData(8) = 105 : : For a = 1 To 4 : m_intRotcw(a) = m_intData(a) : Next : : For a = 1 To 4 : m_intRotccw(a) = m_intData(a) : Next : End Sub : : Private Sub btnClockwise_Click(ByVal sender As System.Object, ByVal : e As System.EventArgs) Handles btnClockwise.Click : m_intDirection = ROTATE_CLOCKWISE : m_objTimer1.Start() : End Sub : : Private Sub btnCClockwise_Click(ByVal sender As System.Object, ByVal : e As System.EventArgs) Handles btnCClockwise.Click : m_intDirection = ROTATE_COUNTERCLOCKWISE : m_objTimer1.Start() : End Sub : : Private Sub m_objTimer1_Elapsed(ByVal sender As Object, ByVal e As : System.Timers.ElapsedEventArgs) Handles m_objTimer1.Elapsed : Dim iResult As Integer = 0 : : Select Case m_intDirection : Case ROTATE_NONE : iResult = 1 'Not doing anything so stop the timer, but : should not happen : Case ROTATE_CLOCKWISE : iResult = RotateClockwise() : Case ROTATE_COUNTERCLOCKWISE : iResult = RotateCounterClockwise() : End Select : : If iResult = 1 Then : 'Stop the timer : m_objTimer1.Stop() : End If : End Sub : : Private Function RotateClockwise() As Integer : Dim iRet As Integer = 0 : Static a As Integer = 1 : Static b As Integer = 1 : : If a = 1 And b = 1 Then : 'Initialize rotation : Out(m_intPorta, 105) : Out(m_intPortc, 11) : End If : : Out(m_intPorta, m_intRotcw(b)) : Out(m_intPortc, 11) : Out(m_intPortc, 10) : b = b + 1 : If b > 4 Then : b = 1 : a = a + 1 : End If : : If a = 13 And b = 1 Then : 'End rotation : Out(m_intPorta, 0) : Out(m_intPortc, 11) : Out(m_intPortc, 10) : 'Reset counters : a = 1 : iRet = 1 'To let calling function know that rotation is : complete : End If : : Return iRet : End Function : : Private Function RotateCounterClockwise() As Integer : Dim iRet As Integer = 0 : Static a As Integer = 1 : Static b As Integer = 1 : : If a = 1 And b = 1 Then : 'Initialize rotation : Out(m_intPorta, 105) : Out(m_intPortc, 11) : End If : : Out(m_intPorta, m_intRotcw(b)) : Out(m_intPortc, 11) : Out(m_intPortc, 10) : b = b + 1 : If b > 4 Then : b = 1 : a = a + 1 : End If : : If a = 13 And b = 1 Then : 'End rotation : Out(m_intPorta, 0) : Out(m_intPortc, 11) : Out(m_intPortc, 10) : 'Reset counters : a = 1 : iRet = 1 'To let calling function know that rotation is : complete : End If : : Return iRet : End Function : : Private Sub Out(ByVal int1 As Integer, ByVal int2 As Integer) : 'Dummy sub to avoid commenting out the 'Out' code bits : End Sub : : End Class : : : : : *** Sent via Developersdex http://www.developersdex.com ***
From: Cor Ligthert[MVP] on 23 May 2010 03:23 Be aware your question is not VB6 which is the latest version of Visual Basic which is done in this newsgroup. You are probably better of in this forum, there are two or three guys really good in the stuff around your problem (not me) http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/threads?page=1 Cor "Phillip Holmes" <phillipholmes1(a)btinternet.com> wrote in message news:OiCGSdh#KHA.4316(a)TK2MSFTNGP04.phx.gbl... > Referring to the original query, I did it this way, which I think allows > the process to create and run on its own thread which will avoid your PC > from locking up during the operation. Regards, Phil. > > Public Class Form1 > Private Const ROTATE_NONE = 0 > Private Const ROTATE_CLOCKWISE = 1 > Private Const ROTATE_COUNTERCLOCKWISE = 2 > > Private WithEvents m_objTimer1 As New System.Timers.Timer() > > Private m_intDirection As Integer > Private m_intPorta As Integer > Private m_intPortc As Integer > Private m_intRotcw(4), m_intRotccw(4) As Integer > Private m_intData(8) As Integer > > Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As > System.EventArgs) Handles MyBase.Load > 'Initialize > Dim a As Integer > > m_objTimer1.Interval = 1000 '1 Second > > m_intPorta = &H378 > m_intPortc = m_intPorta + 2 > > m_intData(1) = 153 > m_intData(2) = 150 > m_intData(3) = 102 > m_intData(4) = 105 > m_intData(5) = 102 > m_intData(6) = 150 > m_intData(7) = 153 > m_intData(8) = 105 > > For a = 1 To 4 > m_intRotcw(a) = m_intData(a) > Next > > For a = 1 To 4 > m_intRotccw(a) = m_intData(a) > Next > End Sub > > Private Sub btnClockwise_Click(ByVal sender As System.Object, ByVal > e As System.EventArgs) Handles btnClockwise.Click > m_intDirection = ROTATE_CLOCKWISE > m_objTimer1.Start() > End Sub > > Private Sub btnCClockwise_Click(ByVal sender As System.Object, ByVal > e As System.EventArgs) Handles btnCClockwise.Click > m_intDirection = ROTATE_COUNTERCLOCKWISE > m_objTimer1.Start() > End Sub > > Private Sub m_objTimer1_Elapsed(ByVal sender As Object, ByVal e As > System.Timers.ElapsedEventArgs) Handles m_objTimer1.Elapsed > Dim iResult As Integer = 0 > > Select Case m_intDirection > Case ROTATE_NONE > iResult = 1 'Not doing anything so stop the timer, but > should not happen > Case ROTATE_CLOCKWISE > iResult = RotateClockwise() > Case ROTATE_COUNTERCLOCKWISE > iResult = RotateCounterClockwise() > End Select > > If iResult = 1 Then > 'Stop the timer > m_objTimer1.Stop() > End If > End Sub > > Private Function RotateClockwise() As Integer > Dim iRet As Integer = 0 > Static a As Integer = 1 > Static b As Integer = 1 > > If a = 1 And b = 1 Then > 'Initialize rotation > Out(m_intPorta, 105) > Out(m_intPortc, 11) > End If > > Out(m_intPorta, m_intRotcw(b)) > Out(m_intPortc, 11) > Out(m_intPortc, 10) > b = b + 1 > If b > 4 Then > b = 1 > a = a + 1 > End If > > If a = 13 And b = 1 Then > 'End rotation > Out(m_intPorta, 0) > Out(m_intPortc, 11) > Out(m_intPortc, 10) > 'Reset counters > a = 1 > iRet = 1 'To let calling function know that rotation is > complete > End If > > Return iRet > End Function > > Private Function RotateCounterClockwise() As Integer > Dim iRet As Integer = 0 > Static a As Integer = 1 > Static b As Integer = 1 > > If a = 1 And b = 1 Then > 'Initialize rotation > Out(m_intPorta, 105) > Out(m_intPortc, 11) > End If > > Out(m_intPorta, m_intRotcw(b)) > Out(m_intPortc, 11) > Out(m_intPortc, 10) > b = b + 1 > If b > 4 Then > b = 1 > a = a + 1 > End If > > If a = 13 And b = 1 Then > 'End rotation > Out(m_intPorta, 0) > Out(m_intPortc, 11) > Out(m_intPortc, 10) > 'Reset counters > a = 1 > iRet = 1 'To let calling function know that rotation is > complete > End If > > Return iRet > End Function > > Private Sub Out(ByVal int1 As Integer, ByVal int2 As Integer) > 'Dummy sub to avoid commenting out the 'Out' code bits > End Sub > > End Class > > > > > *** Sent via Developersdex http://www.developersdex.com ***
From: Mike Williams on 23 May 2010 06:38 "Cor Ligthert[MVP]" <Notmyfirstname(a)planet.nl> wrote in message news:%23wmOYjk%23KHA.348(a)TK2MSFTNGP06.phx.gbl... > Be aware your question is not VB6 which is > the latest version of Visual Basic which is > done in this newsgroup. Actually, VB6 is the latest version of Visual Basic, period! The thing dealt with at the forum you posted a link to is not Visual Basic. It is an imposter. Mike
From: Cor Ligthert[MVP] on 23 May 2010 09:32
"Mike Williams" <Mike(a)WhiskeyAndCoke.com> wrote in message > Actually, VB6 is the latest version of Visual Basic, period! The thing dealt > with at the forum you posted a link to is not Visual Basic. It is an > imposter. > This implies that you take with this message the ownership of the brand name Visual Basic, I assume you can defend that right in any American courtroom? I always thought Microsoft was the owner, so you see, never to old to learn. |