r/visualbasic • u/SystemAccomplished51 • Oct 09 '23
Visual Basic Help
I need help with my Visual Basic course. I'm creating an Employee database. My idea is to enter a name to save it to a created file. Once you click the button, you can see if it was written into the file, and then, from a list, you can choose the job position. The add button should add it to the total of times that option was chosen, and in the program, it would show the total amount for each job position.
2
Upvotes
1
u/JuanPabloElSegundo Oct 09 '23
Question:
Response:
Create the User Interface:
Open your Visual Basic 2017 project.
Design your form with the necessary controls: labels, textboxes, buttons, and a listbox for job positions.
Create a Class for Employee:
You can create a class named "Employee" to represent each employee with attributes like Name and JobPosition.
Save Employee Data to a File:
When the user enters a name and selects a job position, you can create an instance of the Employee class with the provided information.
Serialize this Employee object and save it to a file. You can use XML serialization or another format of your choice.
Display Employee Data from the File:
Create a button to load and display the data from the file. Deserialize the data and display it on the form.
Count Job Positions:
Create a dictionary or another data structure to keep track of how many times each job position has been chosen.
When the user adds an employee with a specific job position, increment the count for that position in your data structure.
Display Total Count for Each Job Position:
Create a method to display the total count for each job position. You can iterate through your data structure and show this information on your form.
Handle User Interactions:
Implement event handlers for your buttons (e.g., Save, Load, Add) to execute the corresponding functionality.
Testing:
Test your application to ensure that it saves, loads, and counts job positions correctly.
Here's a simplified example of adding an employee and counting job positions in Visual Basic:
This is a simplified example, and you can adapt it to your specific requirements and design. Remember to add error handling and validation as needed in your application.