timer or delay...

Discussion in 'AutoCAD' started by nalsur8, Jan 28, 2005.

  1. nalsur8

    nalsur8 Guest

    vba autocad have timer or not if not how to make it
    let say in textbox or image every second will be change
    any picture or number
     
    nalsur8, Jan 28, 2005
    #1
  2. nalsur8

    fantum Guest

    Given a UserForm named UserForm1 with a TextBox named TextBox1 and a module, put this in the module:

    Public Declare Function SetTimer Lib "user32" (ByVal hWnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
    Public Declare Function KillTimer Lib "user32" (ByVal hWnd As Long, ByVal nIDEvent As Long) As Long
    Public idTimer As Long

    Public Sub TimerFunc(ByVal hWnd As Long, ByVal uMsg As Long, ByVal IDEvent As Long, ByVal dwTime As Long)
    UserForm1.TextBox1.Text = CStr(Val(UserForm1.TextBox1.Text) + 1)
    End Sub


    and this in the userform:

    Private Sub UserForm_Initialize()
    'timer with 1000 ms period
    idTimer = SetTimer(0, 0, 1000, AddressOf TimerFunc)
    End Sub

    Private Sub UserForm_Terminate()
    If 0 <> idTimer Then
    Call KillTimer(0, idTimer)
    End If
    End Sub
     
    fantum, Jan 28, 2005
    #2
  3. nalsur8

    nalsur8 Guest

    it's can change number to alphabet (ABC...Z)
    actualy what i want is, in userform have 3 button
    and 1 textbox, textbox1 funtion for alphabet only and change
    random automatic when the user press 1 of 3 button and value in
    textbox1 will be change as random,
    let say in textbox1 value is K and pause til user press
    1 of 3 button, when user press the button textbox1 change
    to next alphabet as randomly it's can?

    module, put this in the module:
    nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
     
    nalsur8, Jan 29, 2005
    #3
  4. nalsur8

    fantum Guest

    I don't see where a timer would be involved in generating a random letter. See the documentation for the Rnd function for generating a random number. You can translate the generated number into a letter using an array look-up or the Chr function.
     
    fantum, Jan 31, 2005
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.