Click here to Skip to main content
15,895,256 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Need help with SQL query Pin
dan!sh 3-Sep-09 3:34
professional dan!sh 3-Sep-09 3:34 
GeneralRe: Need help with SQL query Pin
sazd13-Sep-09 3:38
sazd13-Sep-09 3:38 
AnswerRe: Need help with SQL query Pin
Pasan1483-Sep-09 5:04
Pasan1483-Sep-09 5:04 
GeneralRe: Need help with SQL query Pin
sazd13-Sep-09 8:39
sazd13-Sep-09 8:39 
QuestionTimer set time click Pin
Bob Beaubien2-Sep-09 21:52
Bob Beaubien2-Sep-09 21:52 
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 
Hi Bob,

Besides what the other two already told you, I strongly recommend you to not fire the button click event with the timer tick event.

Instead, it is much better practice, to move the code from the button's click event to its own Sub, and then call this sub both in the button's click event and in the timer's tick event.

So instead of this:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  MsgBox("Jiihuu!!!")
End Sub

Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
  Button1.PerformClick()
End Sub


it's better to build your app like this:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  MyMessageBox()
End Sub

Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
  MyMessageBox()
End Sub

Private Sub MyMessageBox()
  MsgBox("Jiihuu!!!")
End Sub


This will make future development a lot easier, for example if at some point you want the code to execute in different manners:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  MyMessageBox(" Executed by Button1")
End Sub

Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
  MyMessageBox(" Executed by Timer1 at " & Now.ToShortTimeString)
End Sub

Private Sub MyMessageBox(Byval ExtraMessage As String)
  MsgBox("Jiihuu!!!" & ExtraMessage)
End Sub


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

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 
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 

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.