Form1.vb
资源名称:exercise6.zip [点击查看]
上传用户:yauxiao
上传日期:2022-06-30
资源大小:250k
文件大小:10k
源码类别:
文章/文档
开发平台:
Visual Basic
- Public Class Form1
- 'my best solution
- 'author Bekarystanov Talgat
- Dim hasSaveingsTime As Boolean
- Dim setOff As String
- Public Sub New()
- ' This call is required by the Windows Form Designer.
- InitializeComponent()
- xYear.Value = Date.Today.Year
- xMonth.SelectedIndex = Date.Today.Month - 1 'Index started from 0 like array
- xHour.Value = Date.Now.Hour
- xMinute.Value = Date.Now.Minute
- xSecond.Value = Date.Now.Second
- ' Add any initialization after the InitializeComponent() call.
- End Sub
- Private Sub xMonth_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles xMonth.SelectedIndexChanged
- MonthCalendar1.SetDate(Convert.ToDateTime(xYear.Value.ToString & "-" & (xMonth.SelectedIndex + 1).ToString & "-" & Date.Today.Day.ToString))
- End Sub
- Private Sub MonthCalendar1_DateChanged(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles MonthCalendar1.DateChanged
- xMonth.SelectedIndex = MonthCalendar1.SelectionStart.Month - 1
- xYear.Value = MonthCalendar1.SelectionStart.Year
- End Sub
- Private Sub xYear_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles xYear.ValueChanged
- MonthCalendar1.SetDate(Convert.ToDateTime(xYear.Value.ToString & "-" & Today.Month.ToString & "-" & Date.Today.Day.ToString))
- End Sub
- Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
- Select Case ComboBox1.SelectedIndex
- Case 0, 1, 2, 5, 8, 9, 10, 12, 14, 17, 21, 28, 30, 33, 34, 35, 36, 37, 38, 40, 41, 43, 45, 47, 48
- hasSaveingsTime = False
- Case Else
- hasSaveingsTime = True
- End Select
- Select Case ComboBox1.SelectedIndex
- Case 0
- setOff = "-720"
- Case 1
- setOff = "-660"
- Case 2
- setOff = "-600"
- Case 3
- setOff = "-540"
- Case 4
- setOff = "-480"
- Case 5
- setOff = "-420"
- Case 6
- setOff = "-420"
- Case 7
- setOff = "-360"
- Case 8
- setOff = "-360"
- Case 9
- setOff = "-360"
- Case 10
- setOff = "-300"
- Case 11
- setOff = "-300"
- Case 12
- setOff = "-300"
- Case 13
- setOff = "-240"
- Case 14
- setOff = "-210"
- Case 15
- setOff = "-180"
- Case 16
- setOff = "-180"
- Case 17
- setOff = "-120"
- Case 18
- setOff = "-060"
- Case 19
- setOff = "+000"
- Case 20
- setOff = "+000"
- Case 21
- setOff = "+060"
- Case 22
- setOff = "+060"
- Case 23
- setOff = "+060"
- Case 24
- setOff = "+120"
- Case 25
- setOff = "+120"
- Case 26
- setOff = "+120"
- Case 27
- setOff = "+120"
- Case 28
- setOff = "+120"
- Case 29
- setOff = "+180"
- Case 30
- setOff = "+180"
- Case 31
- setOff = "+180"
- Case 32
- setOff = "+240"
- Case 33
- setOff = "+270"
- Case 34
- setOff = "+300"
- Case 35
- setOff = "+330"
- Case 36
- setOff = "+360"
- Case 37
- setOff = "+420"
- Case 38
- setOff = "+480"
- Case 39
- setOff = "+480"
- Case 40
- setOff = "+540"
- Case 41
- setOff = "+570"
- Case 42
- setOff = "+570"
- Case 43
- setOff = "+600"
- Case 44
- setOff = "+600"
- Case 45
- setOff = "+600"
- Case 46
- setOff = "+660"
- Case 47
- setOff = "+720"
- Case 48
- setOff = "+720 "
- End Select
- If hasSaveingsTime = False Then
- CheckBox1.Enabled = False
- Else
- CheckBox1.Enabled = True
- End If
- tm.Text = ComboBox1.Text
- End Sub
- Private Sub Applyb_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Applyb.Click
- If CheckBox1.Enabled = True And CheckBox1.Checked Then
- MsgBox("Applied..." & Chr(13) & Chr(10) & "================================" & Chr(13) & Chr(10) & "Year= " & Date.Today.Year & Chr(13) & Chr(10) & "Month= " & Date.Today.Month & Chr(13) & Chr(10) & "Day= " & Today.Day & Chr(13) & Chr(10) & "Hour= " & xHour.Value & Chr(13) & Chr(10) & "Minute= " & xMinute.Value & Chr(13) & Chr(10) & "Second= " & xSecond.Value & Chr(13) & Chr(10) & "Timezone= " & ComboBox1.Text.ToString & Chr(13) & Chr(10) & "Offset from GMT= " & setOff & " minutes" & Chr(13) & Chr(10) & "Auto daylight= " & hasSaveingsTime & Chr(13) & Chr(10) & "================================" & Chr(13) & Chr(10) & "(Time saved)", MsgBoxStyle.OkOnly, "Exercise 6")
- Else
- MsgBox("Applied..." & Chr(13) & Chr(10) & "================================" & Chr(13) & Chr(10) & "Year= " & Date.Today.Year & Chr(13) & Chr(10) & "Month= " & Date.Today.Month & Chr(13) & Chr(10) & "Day= " & Today.Day & Chr(13) & Chr(10) & "Hour= " & xHour.Value & Chr(13) & Chr(10) & "Minute= " & xMinute.Value & Chr(13) & Chr(10) & "Second= " & xSecond.Value & Chr(13) & Chr(10) & "Timezone= " & ComboBox1.Text.ToString & Chr(13) & Chr(10) & "Offset from GMT= " & setOff & " minutes" & Chr(13) & Chr(10) & "Auto daylight= " & hasSaveingsTime & Chr(13) & Chr(10) & "================================" & Chr(13) & Chr(10) & "(Time not saved)", MsgBoxStyle.OkOnly, "Exercise 6")
- End If
- End Sub
- Private Sub okb_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles okb.Click
- If CheckBox1.Enabled = True And CheckBox1.Checked Then
- MsgBox("OK..." & Chr(13) & Chr(10) & "================================" & Chr(13) & Chr(10) & "Year= " & Date.Today.Year & Chr(13) & Chr(10) & "Month= " & Date.Today.Month & Chr(13) & Chr(10) & "Day= " & Today.Day & Chr(13) & Chr(10) & "Hour= " & xHour.Value & Chr(13) & Chr(10) & "Minute= " & xMinute.Value & Chr(13) & Chr(10) & "Second= " & xSecond.Value & Chr(13) & Chr(10) & "Timezone= " & ComboBox1.Text.ToString & Chr(13) & Chr(10) & "Offset from GMT= " & setOff & " minutes" & Chr(13) & Chr(10) & "Auto daylight= " & hasSaveingsTime & Chr(13) & Chr(10) & "================================" & Chr(13) & Chr(10) & "(Time saved)", MsgBoxStyle.OkOnly, "Exercise 6")
- Else
- MsgBox("OK..." & Chr(13) & Chr(10) & "================================" & Chr(13) & Chr(10) & "Year= " & Date.Today.Year & Chr(13) & Chr(10) & "Month= " & Date.Today.Month & Chr(13) & Chr(10) & "Day= " & Today.Day & Chr(13) & Chr(10) & "Hour= " & xHour.Value & Chr(13) & Chr(10) & "Minute= " & xMinute.Value & Chr(13) & Chr(10) & "Second= " & xSecond.Value & Chr(13) & Chr(10) & "Timezone= " & ComboBox1.Text.ToString & Chr(13) & Chr(10) & "Offset from GMT= " & setOff & " minutes" & Chr(13) & Chr(10) & "Auto daylight= " & hasSaveingsTime & Chr(13) & Chr(10) & "================================" & Chr(13) & Chr(10) & "(Time not saved)", MsgBoxStyle.OkOnly, "Exercise 6")
- End If
- Me.Close()
- End Sub
- Private Sub Cancelb_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancelb.Click
- If CheckBox1.Enabled = True And CheckBox1.Checked Then
- MsgBox("Cancelled" & Chr(13) & Chr(10) & "================================" & Chr(13) & Chr(10) & "Year= " & Date.Today.Year & Chr(13) & Chr(10) & "Month= " & Date.Today.Month & Chr(13) & Chr(10) & "Day= " & Today.Day & Chr(13) & Chr(10) & "Hour= " & xHour.Value & Chr(13) & Chr(10) & "Minute= " & xMinute.Value & Chr(13) & Chr(10) & "Second= " & xSecond.Value & Chr(13) & Chr(10) & "Timezone= " & ComboBox1.Text.ToString & Chr(13) & Chr(10) & "Offset from GMT= " & setOff & " minutes" & Chr(13) & Chr(10) & "Auto daylight= " & hasSaveingsTime & Chr(13) & Chr(10) & "================================" & Chr(13) & Chr(10) & "(Time saved)", MsgBoxStyle.OkOnly, "Exercise 6")
- Else
- MsgBox("Cancelled" & Chr(13) & Chr(10) & "================================" & Chr(13) & Chr(10) & "Year= " & Date.Today.Year & Chr(13) & Chr(10) & "Month= " & Date.Today.Month & Chr(13) & Chr(10) & "Day= " & Today.Day & Chr(13) & Chr(10) & "Hour= " & xHour.Value & Chr(13) & Chr(10) & "Minute= " & xMinute.Value & Chr(13) & Chr(10) & "Second= " & xSecond.Value & Chr(13) & Chr(10) & "Timezone= " & ComboBox1.Text.ToString & Chr(13) & Chr(10) & "Offset from GMT= " & setOff & " minutes" & Chr(13) & Chr(10) & "Auto daylight= " & hasSaveingsTime & Chr(13) & Chr(10) & "================================" & Chr(13) & Chr(10) & "(Time not saved)", MsgBoxStyle.OkOnly, "Exercise 6")
- End If
- Me.Close()
- End Sub
- Private Sub xam_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles xam.CheckedChanged
- If xHour.Value > 12 And xam.Checked = True Then
- xHour.Value = xHour.Value - 12
- ElseIf xHour.Value <= 12 And xHour.Value > 0 And xam.Checked = True Then
- xHour.Value = xHour.Value
- ElseIf xHour.Value = 0 And xam.Checked = True Then
- xHour.Value = 12
- End If
- End Sub
- Private Sub xpm_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles xpm.CheckedChanged
- If xHour.Value > 12 And xpm.Checked = True Then
- xHour.Value = xHour.Value
- ElseIf xHour.Value < 12 And xHour.Value > 0 And xpm.Checked = True Then
- xHour.Value = xHour.Value + 12
- ElseIf xHour.Value = 12 And xpm.Checked = True Then
- xHour.Value = 0
- End If
- End Sub
- End Class