|
-
October 4th, 2005, 10:29 PM
#1
Event handler
I'm clueless in programming, however i hope the gurus here will be able to help me with source code before 9 October( urgent for my project).
First Situation:I have this blood monitor devide that comes with a software cd. It needs to be install for the program to run. I would like codes that could activate the icon at certain timing without having the user to click on it.(automatic run application). Is it possible?
Second situation: A have this access datasheet that contains the time for prayers. How can i connect that access database to my vb program, and once vb time matches with the time on the datasheet, how to activate an alarm? (continuous running application). The technique is the same as an alarm.
I would greatly appreciate if the codes could be given, as i was stuck with this project for more than a month.now i am seeking help. pls... thanks.
-
October 5th, 2005, 02:37 AM
#2
Re: Event handler
1. Create a scheduled task. You can do that manually in Windows or you can do it programatically. Check the Windows help for "schtasks" for the syntax and call it using Process.Start.
2. ADO.NET: http://www.startvbdotnet.com/ado/default.aspx. You can use a System.Windows.Forms.Timer to set an alarm and do whatever at the end of an time interval.
-
October 5th, 2005, 09:30 AM
#3
Re: Event handler
Thanks for the quick reply. I would like to know how to do scheduled task programatically using vb?
-
October 5th, 2005, 05:37 PM
#4
Re: Event handler
Schtasks.exe is program in the system32 folder. You can run it with various commandline arguments to query, create, edit and delete scheduled tasks. Open "Help and Support" from the Windows Start menu and search for "schtasks" for details of which commandline arguments to use. It is a commandline program, so if you want to get information back from it you'll need to fiddle a bit. I started to use myself about a year or so ago but there was a bug in my Windows installation that crashed it every time I used a particular argument. The same thing worked on another machine so I figured it was my Windows install and gave up.
-
October 5th, 2005, 09:53 PM
#5
Re: Event handler
Can i ask? How do i write codes to compare the time from vb with the computer time using timer function?
-
October 5th, 2005, 10:03 PM
#6
Re: Event handler
I'm not 100% sure what you're asking for but if you have a DateTime object you can compare it to the current time like this:
Code:
Select Case Date.Compare(myDateTime, Date.Now)
Case Is < 0
'myDateTime is before the current time.
Case 0
'myDateTime is equal to the current time.
Case Is > 0
'myDateTime is after the current time.
End Select
Last edited by jmcilhinney; October 5th, 2005 at 10:13 PM.
-
October 6th, 2005, 12:48 AM
#7
Re: Event handler
Oh i shall explain in details. What i mean was.. i have a timer at my current form and a label showing the current time. So once, the vb time matched with my comp following time: (8am, 5pm), it supposed to sound a buzz for 5 mins. how do write it?
-
October 6th, 2005, 02:15 AM
#8
Re: Event handler
I would do it something like this:
Code:
Private nextAlarmTimes As New ArrayList
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.nextAlarmTimes.Add(Date.Today.AddHours(8)) '8 AM
Me.nextAlarmTimes.Add(Date.Today.AddHours(17)) '5 PM
Dim alarmTime As Date
For i As Integer = 0 To Me.nextAlarmTimes.Count - 1 Step 1
alarmTime = CDate(Me.nextAlarmTimes(i))
If Date.Now > alarmTime Then
'This alarm time has already passed.
Me.nextAlarmTimes(i) = alarmTime.AddDays(1)
End If
Next
Me.Timer1.Start()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim alarmTime As Date
For i As Integer = 0 To Me.nextAlarmTimes.Count - 1 Step 1
alarmTime = CDate(Me.nextAlarmTimes(i))
If Date.Now > alarmTime Then
'This alarm time has passed since the last tick.
Me.nextAlarmTimes(i) = alarmTime.AddDays(1)
'Play alarm sound here.
'If you know that only one alarm time will have passed since the last tick there is no point checking the rest.
Return
End If
Next
End Sub
You would get your alarm times from the database rather than using literal values like I have.
As for playing the sound, you might choose to use a WMP object or perhaps something like this class. Just make sure you play the sound asynchronously.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|