KEMBAR78
Employee Direc | PDF | Computer Programming | Computing
0% found this document useful (0 votes)
46 views5 pages

Employee Direc

The document describes a simple employee directory program that allows a user to perform basic CRUD operations on a list of employees stored in a hashset. The program displays a menu with options to add, remove, search for, and view all employees. Based on the user's selection, it will call the appropriate subroutine to perform the requested operation and provide feedback.

Uploaded by

hakdogzhahaha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views5 pages

Employee Direc

The document describes a simple employee directory program that allows a user to perform basic CRUD operations on a list of employees stored in a hashset. The program displays a menu with options to add, remove, search for, and view all employees. Based on the user's selection, it will call the appropriate subroutine to perform the requested operation and provide feedback.

Uploaded by

hakdogzhahaha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

Imports System.Collections.

Generic

Module EmployeeDirectory
Dim employees As New HashSet(Of String)()

Sub Main()
Dim choice As Integer
Dim employeeCounter As Integer = 0

Do
Console.WriteLine(" = = = = = = = = = = = = = = = = =
= = = = = = = = = = =")
Console.WriteLine("
================================================")
Console.WriteLine(" || Simple Employee
Directory ||")
Console.WriteLine("
================================================")
Console.WriteLine(" = = = = = = = = = = = = = = = = =
= = = = = = = = = = =")

Console.WriteLine()

Console.WriteLine("
================================================")
Console.WriteLine(" || [1] Add
Employee ||")
Console.WriteLine("
================================================")
Console.WriteLine(" || [2] Remove
Employee ||")
Console.WriteLine("
================================================")
Console.WriteLine(" || [3] Search
Employee ||")
Console.WriteLine("
================================================")
Console.WriteLine(" || [4] View All
Employees ||")
Console.WriteLine("
================================================")
Console.WriteLine(" || [5] Exit
||")
Console.WriteLine("
================================================")

Console.WriteLine()

Console.WriteLine("
================================================")
Console.Write(" || Enter your choice: ")

Dim input As String = Console.ReadLine()

If Integer.TryParse(input, choice) Then


Console.WriteLine("
================================================")

Select Case choice


Case 1
employeeCounter += 1
AddEmployee(employeeCounter)
Case 2
RemoveEmployee()
Case 3
SearchEmployee()
Case 4
ViewAllEmployees()
Case 5
Console.WriteLine()
Console.WriteLine("
==========================")
Console.WriteLine(" ||
Goodbye! ||")
Console.WriteLine("
==========================")
Case Else
Console.WriteLine()
Console.WriteLine("
================================================")
Console.WriteLine(" || Invalid
choice. Please try again. ||")
Console.WriteLine("
================================================")
Console.WriteLine(" Press
Any Key To Clear !!")
Console.ReadKey()
Console.Beep()
Console.Clear()
End Select
ElseIf String.IsNullOrWhiteSpace(input) Then
Console.WriteLine("
================================================")
Console.WriteLine()
Console.WriteLine("
================================================")
Console.WriteLine(" || Please Input a
non-empty choice ||")
Console.WriteLine("
================================================")
Console.WriteLine(" Press Any Key
To Clear !!")
Console.ReadKey()
Console.Beep()
Console.Clear()
Else
Console.WriteLine("
================================================")
Console.WriteLine()
Console.WriteLine("
================================================")
Console.WriteLine(" || Please choose
only 1/2/3/4/5 ||")
Console.WriteLine("
================================================")
Console.WriteLine(" Press Any Key
To Clear !!")
Console.ReadKey()
Console.Beep()
Console.Clear()
End If
Loop While choice <> 5
End Sub
Sub AddEmployee(employeeCounter As Integer)
Console.Write(" || Enter the employee's name: ")
Dim employeeName As String = Console.ReadLine()

Console.WriteLine("
===============================================")

Console.WriteLine()
If String.IsNullOrWhiteSpace(employeeName) Then
Console.WriteLine("
=========================================================")
Console.WriteLine(" || Please Input a non-empty
employee name. ||")
Console.WriteLine("
=========================================================")
ElseIf employees.Contains(employeeName) Then
Console.WriteLine("
=========================================================")
Console.WriteLine($" || Employee '{employeeName}' is
already in the directory.")
Console.WriteLine("
=========================================================")
Else
employees.Add(employeeName)
Console.WriteLine("
==================================================================")
Console.WriteLine($" || Employee '{employeeName}' added to
the directory as employee {employeeCounter}.")
Console.WriteLine("
==================================================================")
employeeCounter += 1
End If
Console.WriteLine(" Press Any Key To
Clear !!")
Console.ReadKey()
Console.Beep()
Console.Clear()
End Sub

Sub RemoveEmployee()
Console.WriteLine("
=====================================================================")
Console.Write(" || Enter the name of the employee to remove: ")
Dim employeeName As String = Console.ReadLine()
Console.WriteLine("
=====================================================================")

Console.WriteLine()

If employees.Contains(employeeName) Then
employees.Remove(employeeName)
Console.WriteLine("
=========================================================")
Console.WriteLine($" || Employee '{employeeName}'
removed from the directory.")
Console.WriteLine("
=========================================================")
Else
Console.WriteLine("
==========================================================")
Console.WriteLine($" || Employee '{employeeName}' not
found in the directory.")
Console.WriteLine("
==========================================================")
End If
Console.WriteLine(" Press Any Key to
Clear!!")
Console.ReadKey()
Console.Beep()
Console.Clear()
End Sub

Sub SearchEmployee()
Console.WriteLine("
=============================================================")
Console.Write(" || Enter the name of the employee to search:
")
Dim employeeName As String = Console.ReadLine()
Console.WriteLine("
=============================================================")

Console.WriteLine()

If employees.Contains(employeeName) Then
Console.WriteLine("
=============================================================")
Console.WriteLine($" || Employee '{employeeName}'
found in the directory.")
Console.WriteLine("
=============================================================")
Else
Console.WriteLine("
=============================================================")
Console.WriteLine($" || Employee '{employeeName}' not
found in the directory.")
Console.WriteLine("
=============================================================")
End If
Console.WriteLine(" Press Any Key to Clear
!!")
Console.ReadKey()
Console.Beep()
Console.Clear()
End Sub

Sub ViewAllEmployees()
Console.WriteLine()
Console.WriteLine("
=======================================")
Console.WriteLine(" || All Employees Names
||")
Console.WriteLine("
=======================================")
Console.WriteLine()

Dim employeeCounter As Integer = 1


For Each employee As String In employees
Console.WriteLine("
==================================================")
Console.WriteLine($" || {employeeCounter} -
{employee}")
employeeCounter += 1
Console.WriteLine("
==================================================")
Next
Console.WriteLine(" Press Any Key to
Exit!!")
Console.ReadKey()
Console.Beep()
Console.Clear()
End Sub
End Module

You might also like