-
Notifications
You must be signed in to change notification settings - Fork 0
/
Home.vb
43 lines (35 loc) · 1.3 KB
/
Home.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
Public Class Home
Private WithEvents updateTimer As New Timer()
Private Sub Home_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim currentTime As DateTime = DateTime.Now()
Dim greeting As String
Dim userName As String = PresentUserData.Item("name")
If currentTime.Hour < 4 Then
greeting = "Welcome, "
ElseIf currentTime.Hour < 12 Then
greeting = "Good Morning, "
ElseIf currentTime.Hour < 18 Then
greeting = "Good Afternoon, "
Else
greeting = "Good Evening, "
End If
greeting += userName
greetingLabel.Text = greeting
SetTimeInterval()
DisplayCurrentTime()
updateTimer.Start()
End Sub
Private Sub DisplayCurrentTime()
Dim currentDateTime As DateTime = DateTime.Now()
Dim formatedString As String = currentDateTime.ToString("dd/MM/yyyy - HH:mm")
datetime_label.Text = formatedString
End Sub
Private Sub UpdateTimerTick(sender As Object, e As EventArgs) Handles updateTimer.Tick
DisplayCurrentTime()
SetTimeInterval()
End Sub
Private Sub SetTimeInterval()
Dim timeLeft As Integer = 60 - DateTime.Now.Second
updateTimer.Interval = timeLeft * 1000
End Sub
End Class