-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |