Click here to Skip to main content
15,890,438 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
AnswerRe: Is it Possible to build a Processor which understands MSIL code. Pin
Spectre_00118-Jan-11 7:25
Spectre_00118-Jan-11 7:25 
GeneralRe: Is it Possible to build a Processor which understands MSIL code. Pin
vytheese18-Jan-11 20:49
professionalvytheese18-Jan-11 20:49 
QuestionConfig File with multiple profiles.. Pin
programmervb.netc++12-Jan-11 7:28
programmervb.netc++12-Jan-11 7:28 
AnswerRe: Config File with multiple profiles.. Pin
Eddy Vluggen13-Jan-11 7:11
professionalEddy Vluggen13-Jan-11 7:11 
GeneralRe: Config File with multiple profiles.. Pin
programmervb.netc++13-Jan-11 9:28
programmervb.netc++13-Jan-11 9:28 
GeneralRe: Config File with multiple profiles.. Pin
Eddy Vluggen13-Jan-11 9:46
professionalEddy Vluggen13-Jan-11 9:46 
AnswerRe: Config File with multiple profiles.. Pin
#realJSOP13-Jan-11 9:28
mve#realJSOP13-Jan-11 9:28 
QuestionWhats wrong with my code? [modified] Pin
Herboren11-Jan-11 16:04
Herboren11-Jan-11 16:04 
I have tried and tried and tried and im so frustrated with trying ot get it to work. It started with the elapsed time reaching zero and the decrementing into the negatives. I fixed that and it stays at 00:00:00, but now when I reset the time from the date time picker it then starts from its original position at 00:00:00 and the decrements once again into the negatives. Also when I specify globally the seconds say at 15, its starts at a random number, usually it starts at 10 and counts down or it will start at 3 and count down, but if I were to declare it within the tick method it starts it where I want it to, but then the time doesn't decrement. Im so stranded I dont even know where to go from here or even how to fix it.

Public Class Form1
    Dim Drag, boolShortBreak, boolLongBreak As Boolean
    Dim X As Integer
    Dim Y As Integer

    'Set Alarm Time for 15 Minutes (Is seconds to reduce countdown when testing
    Public Shared alarmTime15 As Date = Date.Now.AddSeconds(15)
    'Set Alarm Time for 30 Minutes
    Public Shared alarmTime30 As Date = Date.Now.AddMinutes(30)

    'Update Label to show system time
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrSystemTime.Tick
        Label4.Text = TimeOfDay

        'Check Date Time Picker if value matches system time
        CheckDTP()
    End Sub

    'No form border style present
    'If mouse down get Mouse position
    Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
        Drag = True
        X = Windows.Forms.Cursor.Position.X - Me.Left
        Y = Windows.Forms.Cursor.Position.Y - Me.Top
    End Sub

    'No form border style present
    'Get position of form when mouse is dragged(mouse down)
    Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
        If Drag = True Then
            Me.Left = Windows.Forms.Cursor.Position.X - X
            Me.Top = Windows.Forms.Cursor.Position.Y - Y
        End If

    End Sub

    'Release form from being dragged on mouse up
    Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp
        Drag = False
    End Sub

    '15 minute timer subtracted from system time
    Private Sub tmrStart15_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrStart.Tick
        Select Case True

            'date time picker bool for short break (implies 15min break)
            Case boolShortBreak

                Dim remainingTime15 As TimeSpan = alarmTime15.Subtract(Date.Now)
                Label5.Text = String.Format("{0}:{1:d2}:{2:d2}", remainingTime15.Hours, remainingTime15.Minutes, remainingTime15.Seconds)

                'If 15min reaches zero, stop timer and set bool to false
                If remainingTime15.Duration.Seconds = 0 Then
                    Stop_Clock()
                    boolShortBreak = False
                End If
                'date time picker bool for long break (implies 30min break)
            Case boolLongBreak

                Dim remainingTime30 As TimeSpan = alarmTime30.Subtract(Date.Now)
                Label5.Text = String.Format("{0}:{1:d2}:{2:d2}", remainingTime30.Hours, remainingTime30.Minutes, remainingTime30.Seconds)

                'If 30min reaches zero, stop timer and set bool to false
                If remainingTime30.Duration.Seconds = 0 Then
                    Stop_Clock()
                    boolLongBreak = False
                End If
        End Select
    End Sub

    'Check if date time picker values match system time
    'If so enable timer based on either 15min break or 30min break
    'using select case within the tmrStart

    'bools choose whether it is a 15min break or 30min break
    Public Sub CheckDTP()
        If dtp1.Text = Label4.Text Then
            boolShortBreak = True
            tmrStart.Enabled = True
        End If

        If dtp2.Text = Label4.Text Then
            boolLongBreak = True
            tmrStart.Enabled = True
        End If

        If dtp3.Text = Label4.Text Then
            boolShortBreak = True
            tmrStart.Enabled = True
        End If
    End Sub

    'Used to stop the tmrStart Timer
    Private Sub Stop_Clock()
        tmrStart.Stop()
        tmrStart.Enabled = False
    End Sub

End Class


I set Date.Now.AddSeconds so I didnt have to wait 15min for the results to show up. Its supposed to be Date.Now.AddMinutes(15). D'Oh! | :doh:

modified on Tuesday, January 11, 2011 11:22 PM

AnswerRe: Whats wrong with my code? Pin
Luc Pattyn11-Jan-11 16:38
sitebuilderLuc Pattyn11-Jan-11 16:38 
GeneralRe: Whats wrong with my code? Pin
Herboren11-Jan-11 17:25
Herboren11-Jan-11 17:25 
GeneralRe: Whats wrong with my code? Pin
Luc Pattyn11-Jan-11 17:40
sitebuilderLuc Pattyn11-Jan-11 17:40 
GeneralRe: Whats wrong with my code? Pin
Herboren11-Jan-11 18:09
Herboren11-Jan-11 18:09 
GeneralRe: Whats wrong with my code? Pin
Luc Pattyn11-Jan-11 18:24
sitebuilderLuc Pattyn11-Jan-11 18:24 
GeneralRe: Whats wrong with my code? Pin
Herboren11-Jan-11 18:29
Herboren11-Jan-11 18:29 
AnswerRe: Whats wrong with my code? Pin
Brady Kelly14-Jan-11 1:52
Brady Kelly14-Jan-11 1:52 
Questionruntime Pin
messages7-Jan-11 21:11
messages7-Jan-11 21:11 
AnswerRe: runtime Pin
Estys7-Jan-11 22:08
Estys7-Jan-11 22:08 
GeneralRe: runtime Pin
messages8-Jan-11 0:08
messages8-Jan-11 0:08 
GeneralRe: runtime Pin
Estys8-Jan-11 0:19
Estys8-Jan-11 0:19 
GeneralRe: runtime Pin
Ashwini K Singh8-Jan-11 2:25
Ashwini K Singh8-Jan-11 2:25 
GeneralRe: runtime Pin
Estys8-Jan-11 2:33
Estys8-Jan-11 2:33 
AnswerRe: runtime Pin
Abhinav S8-Jan-11 3:08
Abhinav S8-Jan-11 3:08 
QuestionTest Message Pin
ahmadfareedkhan7-Jan-11 5:46
ahmadfareedkhan7-Jan-11 5:46 
AnswerRe: Test Message PinPopular
Keith Barrow7-Jan-11 6:14
professionalKeith Barrow7-Jan-11 6:14 
AnswerRe: Test Message Pin
Dave Kreskowiak7-Jan-11 7:18
mveDave Kreskowiak7-Jan-11 7:18 

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.