my ? is this how do i make the two new buttons work like code wise ?? this is attempt like 5 everytime ive played with the code and added buttons ive crashed the program so please help me !! =] also it just adds 1 to the mins and hours
Public Class TimeTest
Dim time As New Time() ' construct Time with zero arguments
' invoked when user clicks the Add 1 to Second button
Private Sub addSecondButton_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles incrementSecondButton.Click
time.Second = (time.Second + 1) Mod 60 ' add 1 to Second
' add one minute if 60 seconds have passed
If time.Second = 0 Then
time.Minute = (time.Minute + 1) Mod 60 ' add 1 to Minute
' add one hour if 60 minutes have passed
If time.Minute = 0 Then
time.Hour = (time.Hour + 1) Mod 24 ' add 1 to Hour
End If
End If
UpdateDisplay() ' update the TextBoxes and output Labels
End Sub ' addSecondButton_Click
' set time based on TextBox values
Private Sub setTimeButton_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles setTimeButton.Click
' ensure that hour, minute and second are in range
Try
If setHourTextBox.Text <> String.Empty Then
time.Hour = Convert.ToInt32(setHourTextBox.Text)
End If
If setMinuteTextBox.Text <> String.Empty Then
time.Minute = Convert.ToInt32(setMinuteTextBox.Text)
End If
If setSecondTextBox.Text <> String.Empty Then
time.Second = Convert.ToInt32(setSecondTextBox.Text)
End If
Catch ex As ArgumentOutOfRangeException
MessageBox.Show("The hour, minute or second was out of range",
"Out of Range", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
UpdateDisplay() ' update the TextBoxes and output Labels
End Sub ' setTimeButton_Click
' update time display
Private Sub UpdateDisplay()
setHourTextBox.Text = Convert.ToString(time.Hour)
setMinuteTextBox.Text = Convert.ToString(time.Minute)
setSecondTextBox.Text = Convert.ToString(time.Second)
output1Label.Text = ("Hour: " & time.Hour & "; Minute: " &
time.Minute & "; Second: " & time.Second)
output2Label.Text = ("Standard time is: " & time.ToString() &
"; Universal Time is: " & time.ToUniversalString())
End Sub ' UpdateDisplay
End Class ' TimeTest
This post has been edited by smohd: 20 November 2011 - 09:16 PM
Reason for edit:: Strength the title

New Topic/Question
Reply



MultiQuote




|