Click here to Skip to main content
16,008,075 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Timer set time click Pin
TheComputerMan2-Sep-09 22:13
TheComputerMan2-Sep-09 22:13 
AnswerRe: Timer set time click Pin
David Skelly2-Sep-09 22:57
David Skelly2-Sep-09 22:57 
AnswerRe: Timer set time click Pin
Johan Hakkesteegt3-Sep-09 0:32
Johan Hakkesteegt3-Sep-09 0:32 
GeneralRe: Timer set time click Pin
Bob Beaubien3-Sep-09 2:49
Bob Beaubien3-Sep-09 2:49 
GeneralRe: Timer set time click Pin
Johan Hakkesteegt3-Sep-09 3:31
Johan Hakkesteegt3-Sep-09 3:31 
GeneralRe: Timer set time click Pin
Bob Beaubien3-Sep-09 3:40
Bob Beaubien3-Sep-09 3:40 
GeneralRe: Timer set time click [modified] Pin
Bob Beaubien3-Sep-09 15:15
Bob Beaubien3-Sep-09 15:15 
GeneralRe: Timer set time click Pin
Johan Hakkesteegt3-Sep-09 20:12
Johan Hakkesteegt3-Sep-09 20:12 
Hi Bob,

You need to move Timer1.Interval = 60000 to where you start the timer.
So for example:
Private Sub Form_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  Timer1.Enabled = True
  Timer1.Interval = 60000 'we should get a tick every 1 minute'
  'if you get a tick more often, you need to increase this number'
  'if you get a tick less often, you need to decrease this number'
  Timer1.Start
End Sub


For your code to run 24 times (once an hour) you need to turn the If and Select Case statements around:
Select Case Now.Hour
        Case 0
            If Now.Minute = 23 Then MyMessageBox(" Executed exactly on time by Timer1 at " & Now.ToShortTimeString)
        Case 1
            If Now.Minute = 23 Then MyMessageBox(" Executed exactly on time by Timer1 at " & Now.ToShortTimeString)
        Case 2
            If Now.Minute = 23 Then MyMessageBox(" Executed exactly on time by Timer1 at " & Now.ToShortTimeString)
        'Etc.'
End Select

Just write a case for each hour, and change the minutes that are checked, according to your needs. So yes, you will need to write 24 lines of code Smile | :)

Although I must agree with Ashfield, that what you are (apparently) trying do, really would work much more reliably with a console application.
If you have never written one, don't worry, it is pretty much the same as the application you have written now, and you wouldn't need to use a timer.

My advice is free, and you may get what you paid for.

GeneralRe: Timer set time click [modified] Pin
Bob Beaubien4-Sep-09 4:32
Bob Beaubien4-Sep-09 4:32 
GeneralRe: Timer set time click Pin
Johan Hakkesteegt6-Sep-09 20:05
Johan Hakkesteegt6-Sep-09 20:05 
GeneralRe: Timer set time click Pin
TheComputerMan4-Sep-09 9:59
TheComputerMan4-Sep-09 9:59 
GeneralRe: Timer set time click Pin
Bob Beaubien5-Sep-09 2:39
Bob Beaubien5-Sep-09 2:39 
AnswerRe: Timer set time click Pin
Ashfield3-Sep-09 1:34
Ashfield3-Sep-09 1:34 
GeneralRe: Timer set time click Pin
Bob Beaubien3-Sep-09 2:50
Bob Beaubien3-Sep-09 2:50 
GeneralRe: Timer set time click Pin
Ashfield3-Sep-09 3:33
Ashfield3-Sep-09 3:33 
Questioninsert excel worksheet also apply the excel formula in vb.net Pin
newdbo2-Sep-09 21:30
newdbo2-Sep-09 21:30 
AnswerRe: insert excel worksheet also apply the excel formula in vb.net Pin
Bob Beaubien2-Sep-09 21:49
Bob Beaubien2-Sep-09 21:49 
AnswerRe: insert excel worksheet also apply the excel formula in vb.net Pin
TheComputerMan2-Sep-09 22:33
TheComputerMan2-Sep-09 22:33 
GeneralRe: insert excel worksheet also apply the excel formula in vb.net Pin
valkyriexp3-Sep-09 14:04
valkyriexp3-Sep-09 14:04 
QuestionAdding controls to Existing Panel at run time in windows application Pin
kjsl2k92-Sep-09 19:16
kjsl2k92-Sep-09 19:16 
AnswerRe: Adding controls to Existing Panel at run time in windows application Pin
Muhammad Mazhar2-Sep-09 19:48
Muhammad Mazhar2-Sep-09 19:48 
GeneralRe: Adding controls to Existing Panel at run time in windows application Pin
kjsl2k92-Sep-09 19:58
kjsl2k92-Sep-09 19:58 
GeneralRe: Adding controls to Existing Panel at run time in windows application Pin
Dave Kreskowiak3-Sep-09 6:41
mveDave Kreskowiak3-Sep-09 6:41 
QuestionPlease help with Inserting value from DataGrid in Database Table Pin
Hammad Mansoor2-Sep-09 19:00
Hammad Mansoor2-Sep-09 19:00 
AnswerRe: Please help with Inserting value from DataGrid in Database Table Pin
TheComputerMan2-Sep-09 22:22
TheComputerMan2-Sep-09 22:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.