Click here to Skip to main content
16,007,504 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: How to manage MDI Child document same as MS Word Editor Pin
Dave Kreskowiak12-Jan-08 6:55
mveDave Kreskowiak12-Jan-08 6:55 
Generalfree disc space Pin
Smithers-Jones10-Jan-08 1:03
Smithers-Jones10-Jan-08 1:03 
GeneralRe: free disc space Pin
Dave Kreskowiak10-Jan-08 4:38
mveDave Kreskowiak10-Jan-08 4:38 
GeneralRe: free disc space Pin
Smithers-Jones10-Jan-08 7:16
Smithers-Jones10-Jan-08 7:16 
QuestionWebbrowser control need help Pin
King of Kingz10-Jan-08 0:58
King of Kingz10-Jan-08 0:58 
GeneralRe: Webbrowser control need help Pin
Dave Kreskowiak10-Jan-08 4:32
mveDave Kreskowiak10-Jan-08 4:32 
QuestionTimer with Date function Pin
Xooku10-Jan-08 0:49
Xooku10-Jan-08 0:49 
GeneralRe: Timer with Date function Pin
Dave Kreskowiak10-Jan-08 4:26
mveDave Kreskowiak10-Jan-08 4:26 
It obvious you don't know how datatype work, or how DateTime works, or how If statements work in the .NET Framework. I would strongly suggest picking up a book on VB.NET for beginners. I lost count of the number of things wrong with this code. But, here are a few of the major problems.

First, In the Timer1_Tick handler, you do NOT nee to call Timer1.Start. It's already started.

The Shutdown method is doing all kinds of thing it does not need to do, if you only understood how Date/Time works in VB.NET, you could reduce this down to a few lines of code.

In the Button1_Click handler, you set Timer1.Enabled to True, then you call Timer1.Start, which does the exact same thing. You only need one of these lines.

FormatDigits isn't even required. The same thing can be accomplished just by specifying the correct formating string where needed.

Your (shortened) code might look something like:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    Label1.Text = DateTime.Now().ToString("HH:mm:ss")
    Shutdown()
End Sub
 
Private Sub Shutdown()
    ' This can be rewritten even shorter, but this is of a level that you should easily understand.
    Dim StartTime As New DateTime(Now.Year, Now.Month, Now.Day, 6, 0, 0)
    Dim EndTime As New DateTime(Now.Year, Now.Month, Now.Day, 11, 16, 0)
    If StartTime <= Now() AndAlso Now() <= EndTime Then
        Timer1.Stop()
        MsgBox("1st piece")
    End If
End Sub
 
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Timer1.Start()
End Sub




A guide to posting questions on CodeProject[^]



Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic
     2006, 2007




QuestionRe: Timer with Date function Pin
Xooku10-Jan-08 20:20
Xooku10-Jan-08 20:20 
GeneralRe: Timer with Date function Pin
Dave Kreskowiak11-Jan-08 1:33
mveDave Kreskowiak11-Jan-08 1:33 
QuestionRe: Timer with Date function Pin
Xooku13-Jan-08 18:03
Xooku13-Jan-08 18:03 
GeneralRe: Timer with Date function Pin
Dave Kreskowiak14-Jan-08 1:43
mveDave Kreskowiak14-Jan-08 1:43 
GeneralRe: Timer with Date function Pin
Xooku14-Jan-08 17:35
Xooku14-Jan-08 17:35 
QuestionRe: Timer with Date function Pin
Xooku16-Jan-08 22:30
Xooku16-Jan-08 22:30 
QuestionRe: Timer with Date function Pin
Xooku20-Jan-08 18:52
Xooku20-Jan-08 18:52 
QuestionMonitoring Power status on Laptop Pin
aspireneo10-Jan-08 0:40
aspireneo10-Jan-08 0:40 
GeneralRe: Monitoring Power status on Laptop Pin
Dave Kreskowiak10-Jan-08 2:05
mveDave Kreskowiak10-Jan-08 2:05 
QuestionHow to load record into a dataset??? Pin
Support1239-Jan-08 20:17
Support1239-Jan-08 20:17 
AnswerHow to READ record FROM a dataset??? Pin
Support1239-Jan-08 22:32
Support1239-Jan-08 22:32 
GeneralRe: How to READ record FROM a dataset??? Pin
Support1239-Jan-08 23:28
Support1239-Jan-08 23:28 
GeneralRe: How to READ record FROM a dataset??? Pin
ChandraRam10-Jan-08 1:39
ChandraRam10-Jan-08 1:39 
AnswerRe: How to READ record FROM a dataset??? Pin
Support12310-Jan-08 3:18
Support12310-Jan-08 3:18 
GeneralRe: How to READ record FROM a dataset??? Pin
Support12310-Jan-08 3:21
Support12310-Jan-08 3:21 
GeneralRe: How to READ record FROM a dataset??? Pin
Dave Kreskowiak10-Jan-08 4:07
mveDave Kreskowiak10-Jan-08 4:07 
GeneralRe: How to READ record FROM a dataset??? Pin
Support12310-Jan-08 18:40
Support12310-Jan-08 18:40 

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.