Results 1 to 7 of 7

Thread: [RESOLVED] Kiosk timer issue

  1. #1

    Thread Starter
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Resolved [RESOLVED] Kiosk timer issue

    I am writing a simple little kisok app that displays the number of days since the last accident and scrolls through a series of safety jpgs.

    When the program loads it asks for date of last reportable accident and stores it. No problem there. I am having 2 issues right now.

    1. I have a timer for scrolling the pictures. I want to be able to break into the loop and update the date & close the program, if necessary. I have the proper code in the keydown event. It works fine if the timer is not working.
    Code:
    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyF12 Then
        StartDate = InputBox("Enter date of last accident")
        lbldays.Caption = DateDiff("d", StartDate, Now)
        '---------------------
        '--set the color
        '---------------------
        SetColor
    ElseIf KeyCode = vbKeyF11 Then
        End
    End If
    End Sub
    The timer code is where the issue lies, I think. I tried adding a DoEvents, but that didn't do it. I update the days field again to take care of midneght date change. Not much overhead involved.
    Code:
    Private Sub Timer1_Timer()
    '
    '-----------------------------------
    ' loop through safety pictures
    '-----------------------------------
    '
    lbldays.Caption = DateDiff("d", StartDate, Now)
    
    GetPicture
    
    '---------------------
    '--set the color
    '---------------------
    SetColor
    
    End Sub
    The loop for getting the picture. It is in test mode right now, so I only have 2 pictures.
    Code:
    Public Function GetPicture()
    Dim pic As Integer
    
    pic = Int(Rnd(1) * 2) + 1
    Dim xx As Picture
    Set xx = LoadPicture("C:\safety" & Trim(pic) & ".jpg")
    Picture1.Picture = xx
    End Function
    I need, in the GetPicture function, to be able to center the picture (horizontally and vertically). Right now, they all just align to the upper left corner and do not fill the whole picture frame area.
    ===================================================
    If your question has been answered, mark the thread as [RESOLVED]

  2. #2

    Thread Starter
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: Kiosk timer issue

    OK, I got the picture stuff fixed. Now, it is just hwo to break into the timer loop to check for a key press.
    ===================================================
    If your question has been answered, mark the thread as [RESOLVED]

  3. #3
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: Kiosk timer issue

    Why don't you disable the timer, like this:
    Code:
    Timer1.Enabled=False    '~~~> Disable Timer
    StartDate = InputBox("Enter date of last accident")
    Timer1.Enabled=True     '~~~> Enable Timer
    ...

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  4. #4
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: Kiosk timer issue

    Using End for unloading the application is not a good practice....

    Links:
    * Why is using the 'End' statement (or VB's "stop" button) a bad idea?
    * Classic VB - How should I close my form/program/class?
    ...

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  5. #5

    Thread Starter
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: Kiosk timer issue

    I need to know when to disbale the timer. Certainly not on every loop. Somehowm, it needs to allow the system (DoEvents) to check for a function key press.
    ===================================================
    If your question has been answered, mark the thread as [RESOLVED]

  6. #6
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: Kiosk timer issue

    Have you changed the KeyPreview property of the Form to TRUE ....???
    Will that help you...??? ...

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  7. #7

    Thread Starter
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: Kiosk timer issue

    That was it! You da man!
    ===================================================
    If your question has been answered, mark the thread as [RESOLVED]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width