Private Sub form_load()
Set txttime = Controls.Add("vb.textbox", "txttime")
Set mytimer = Controls.Add("vb.Timer", "mytimer")
Set mylabel = Controls.Add("vb.label", "mylabel")
Set cmdclose = Controls.Add("vb.commandbutton", "cmdclose")
Set StatusBar1 = Controls.Add("MScomctlLib.sbarctrl.2", "statusbar1")
With cmdclose
.Caption = "&Close"
.Visible = True
.Top = 2000
.Left = (frmtimer.ScaleWidth - cmdclose.Width) \ 2
End With
With mylabel
.AutoSize = True
.Visible = True
.Top = 500
.Left = 1300
.Caption = "Detta är utfört med ren kodning"
End With
With txttime
.Height = 315
.Visible = True
.Top = 1000
.Left = (frmtimer.ScaleWidth - txttime.Width) \ 2
.Alignment = vbCenter
.Locked = True
End With
With mytimer
.Enabled = True
.Interval = 500
End With
With frmtimer
.Caption = "Coding"
.Top = (Screen.Height - Me.Height) \ 2
.Left = (Screen.Width - Me.Width) \ 2
End With
With StatusBar1
.Panels.Add 2, , , sbrDate
.Panels(2).Alignment = sbrCenter
.Panels.Add 3, , , sbrTime
.Panels(3).Alignment = sbrCenter
.Visible = True
.Style = sbrNormal
.Panels(1).AutoSize = sbrSpring
.Panels(1).Alignment = sbrLeft
.Panels(1).Style = sbrText
.Panels(1).Text = "JSC"
End With
End Sub
Sub cmdclose_click()
Dim response As Integer
response = MsgBox("Vill du verkligen avsluta?", vbYesNo + vbQuestion)
If response = vbYes Then
frmgoodbye.Show
Me.Hide
ExitWindowsEx EWX_REBOOT, 0
End If
End Sub
Sub mytimer_timer()
'Visar tiden
txttime.Text = Time
End Sub
'*************************
'Kod för frmGoodbye
Private Sub form_load()
With frmgoodbye
.BorderStyle = 3
.Height = 1500
.Left = 1000
.MousePointer = vbHourglass
.Top = (Screen.Height - Me.Height) \ 2
.Left = (Screen.Width - Me.Width) \ 2
End With
Set mylabel = Controls.Add("vb.label", "mylabel")
Set mytimer = Controls.Add("vb.timer", "mytimer")
With mytimer
.Enabled = True
.Interval = 10000
End With
With mylabel
.Visible = True
.AutoSize = True
.Caption = "Bye-bye!"
.FontSize = 24
.FontBold = True
.Font = "copperplate Gothic Bold"
.Top = (frmgoodbye.ScaleHeight - mylabel.Height) \ 2
.Left = (frmgoodbye.ScaleWidth - mylabel.Width) \ 2
End With
End Sub
Sub mytimer_timer()
Me.Show
Screen.MousePointer = vbHourglass
End
End Sub