Abdu Hamus Assign
Abdu Hamus Assign
Structure Definition
vb
Copy code
Structure student
Dim department As String
Dim division As String
Dim id As String
End Structure
2. Class Initialization
vb
Copy code
Public Class department
Dim newstudent As student
Private stdcount As Integer = 0
Purpose: Sets the default selected item of the department dropdown (cmbdepartment) to
the first option (index 0) when the form loads.
Triggered when the user selects a division from the division list (clbdivision).
Retrieves the first character of the selected division text (e.g., "M" for "Marketing") and
stores it for ID generation.
A utility function that takes a department name as input and returns a short code for the
department.
Returns "xx" if the department name does not match any predefined case.
7. Generate and Display Student ID
vb
Copy code
Private Sub btnid_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnid.Click
stdcount += 1
newstudent.department = cmbdepartment.Text.Trim()
newstudent.division = clbdivision.Text.Trim()
ID Generation Process:
vb
Copy code
Dim departmentnu As String = getdepcode(newstudent.department)
Dim divisionnu As String = newstudent.division.Trim().Substring(0, 1)
Dim str As String = stdcount.ToString("0000")
Dim year As String = (DateTime.Now.Year Mod 2000).ToString()
newstudent.id = departmentnu & divisionnu & "/" & str & "/" & year
vb
Copy code
depdictionary.Add(newstudent.id, newstudent)
btnid.Text = newstudent.id
When hovering over the btnid button, it shows the generated ID.
When the mouse leaves the button, it resets the text to "/////////////////////////".
vb
Copy code
Private Sub btnexit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnexit.Click
Me.Close()
End Sub
Summary