Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Timer Trouble in VB

  • 23-03-2007 3:45pm
    #1
    Closed Accounts Posts: 2,922 ✭✭✭


    Hey, I'm having trouble with my timer in VB. The problem is that the timer counts to the specified value once, and then when it hits the loop there is no delay in between the loop, which is what I need.

    Is their an easier way to do this, like with a counter or something?

    Forgive the code, I'm not a programmer :)
    
    Private Sub RSTimer1_Timer()
    
    Dim i As Integer
    i = 2
    Dim a As Integer
    a = 2
    Do While i = i
    
        If i = a Then
        
            RSTimer1.Enabled = True
            MSComm1.Output = "{IE-1000}"
            RSTimer1.Enabled = False
            i = i + 1
    
        Else
    
            RSTimer1.Enabled = True
            MSComm1.Output = "{IE1000}"
            a = a + 1
            RSTimer1.Enabled = False
        
        End If
        
    
    Loop
    
    
    End Sub 
    
    


Comments

  • Closed Accounts Posts: 884 ✭✭✭NutJob


    Been a long time since i used vb.

    Isn't there a [SIZE=-1]Timer1.Interval= x

    Where x is milliseconds

    [/SIZE]


  • Closed Accounts Posts: 2,922 ✭✭✭Dave


    Yeah, that can be set outside code.

    Here's another stab I made at it, which also doesn't work :(
    
    Dim counter As Integer
    Dim counter2 As Integer
    
    Private Sub Form_Load()
    
    MSComm1.PortOpen = True
    MSComm1.Output = "{IE-1000}"
    
    Timer1.Enabled = True
    
    If counter = 30 Then
        MSComm1.Output = "{IE1000}"
        Timer1.Enabled = False
        counter = 0
        Timer2.Enabled = True
    End If
    
    If counter2 = 30 Then
        MSComm1.Output = "{IE-1000}"
        Timer2.Enabled = False
        counter2 = 0
        Timer1.Enabled = True
    End If
    
    
    
    
    End Sub
    
    Private Sub Timer1_Timer()
    counter = counter + 1
    End Sub
    
    Private Sub Timer2_Timer()
    counter2 = counter2 + 1
    End Sub
    
    


  • Registered Users, Registered Users 2 Posts: 2,152 ✭✭✭dazberry


    I don't know VB, but I think you need to do something like:
    Private Sub Form_Load()
    
    MSComm1.PortOpen = True
    MSComm1.Output = "{IE-1000}"
    counter = 0
    Timer1.Interval = 30000 //fires every ~30 seconds
    Timer1.Enabled = True
    
    End Sub
    
    Private Sub Timer1_Timer()
    
     if counter = 0 then
        MSComm1.Output = "{IE1000}"
     else
        MSComm1.Output = "{IE-1000}"
    
     counter = counter + 1;
     if counter > 1 then counter = 0;
    End Sub
    
    
    

    HTH

    D.


  • Closed Accounts Posts: 2,922 ✭✭✭Dave


    I got it fixed anyway. I'll post up the code if anyone wants it?


Advertisement