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.
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 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 loop for getting the picture. It is in test mode right now, so I only have 2 pictures.Code:Private Sub Timer1_Timer() ' '----------------------------------- ' loop through safety pictures '----------------------------------- ' lbldays.Caption = DateDiff("d", StartDate, Now) GetPicture '--------------------- '--set the color '--------------------- SetColor End Sub
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.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




Reply With Quote