Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
ewdlop authored Dec 27, 2024
1 parent 9eb4d55 commit a6900e3
Showing 1 changed file with 106 additions and 0 deletions.
106 changes: 106 additions & 0 deletions Friends'Manager.linq
Original file line number Diff line number Diff line change
@@ -0,0 +1,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

0 comments on commit a6900e3

Please sign in to comment.