-
Notifications
You must be signed in to change notification settings - Fork 0
/
Friends'Manager.linq
106 lines (68 loc) · 2.62 KB
/
Friends'Manager.linq
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<Query Kind="VBProgram" />
Sub Main
End Sub
Public Class Form1
' A list to store friends' details
Private friendsList As New List(Of String)
' Add Friend Button Click
Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click
Dim name As String = txtName.Text
Dim birthday As String = txtBirthday.Text
If String.IsNullOrWhiteSpace(name) OrElse String.IsNullOrWhiteSpace(birthday) Then
MessageBox.Show("Please enter both name and birthday.", "Error")
Return
End If
' Add friend to the list
Dim friendInfo As String = $"Name: {name}, Birthday: {birthday}"
friendsList.Add(friendInfo)
MessageBox.Show($"{name} added to your friends list!", "Success")
' Clear input fields
txtName.Clear()
txtBirthday.Clear()
End Sub
' View Friends Button Click
Private Sub btnView_Click(sender As Object, e As EventArgs) Handles btnView.Click
' Clear the list box
lstFriends.Items.Clear()
' Display all friends
For Each friend In friendsList
lstFriends.Items.Add(friend)
Next
End Sub
Private Sub btnCheckBirthday_Click(sender As Object, e As EventArgs) Handles btnCheckBirthday.Click
Dim today As String = DateTime.Now.ToString("MM/dd")
Dim birthdayFriends As New List(Of String)
For Each friendInfo In friendsList
Dim parts As String() = friendInfo.Split(","c)
If parts.Length > 1 Then
Dim birthday As String = parts(1).Replace("Birthday: ", "").Trim()
If birthday.StartsWith(today) Then
birthdayFriends.Add(parts(0).Replace("Name: ", "").Trim())
End If
End If
Next
If birthdayFriends.Count > 0 Then
MessageBox.Show($"Today is the birthday of: {String.Join(", ", birthdayFriends)}", "Birthday Reminder")
Else
MessageBox.Show("No birthdays today!", "Birthday Reminder")
End If
End Sub
Private Sub btnCheckBirthday_Click(sender As Object, e As EventArgs) Handles btnCheckBirthday.Click
Dim today As String = DateTime.Now.ToString("MM/dd")
Dim birthdayFriends As New List(Of String)
For Each friendInfo In friendsList
Dim parts As String() = friendInfo.Split(","c)
If parts.Length > 1 Then
Dim birthday As String = parts(1).Replace("Birthday: ", "").Trim()
If birthday.StartsWith(today) Then
birthdayFriends.Add(parts(0).Replace("Name: ", "").Trim())
End If
End If
Next
If birthdayFriends.Count > 0 Then
MessageBox.Show($"Today is the birthday of: {String.Join(", ", birthdayFriends)}", "Birthday Reminder")
Else
MessageBox.Show("No birthdays today!", "Birthday Reminder")
End If
End Sub
End Class