vb学生管理系统代码
时间: 2023-08-04 11:00:22 浏览: 60
VB学生管理系统的代码可以根据具体需求而有所不同,下面给出一个简单示例:
```
' 学生类模块
Public Class Student
Public Property Name As String
Public Property Age As Integer
Public Property Grade As Integer
' 构造函数
Public Sub New(name As String, age As Integer, grade As Integer)
Me.Name = name
Me.Age = age
Me.Grade = grade
End Sub
End Class
' 学生管理系统主模块
Public Class StudentManagementSystem
Public Students As New List(Of Student)
' 添加学生
Public Sub AddStudent(name As String, age As Integer, grade As Integer)
Dim student As New Student(name, age, grade)
Students.Add(student)
End Sub
' 查询学生
Public Function SearchStudent(name As String) As Student
For Each student As Student In Students
If student.Name = name Then
Return student
End If
Next
Return Nothing
End Function
' 删除学生
Public Sub DeleteStudent(name As String)
Dim student As Student = SearchStudent(name)
If student IsNot Nothing Then
Students.Remove(student)
End If
End Sub
End Class
' 示例代码
Public Sub Main()
' 创建学生管理系统对象
Dim system As New StudentManagementSystem()
' 添加学生
system.AddStudent("张三", 17, 10)
system.AddStudent("李四", 16, 9)
' 查询学生
Dim student As Student = system.SearchStudent("张三")
Console.WriteLine("姓名:" & student.Name & " 年龄:" & student.Age & " 年级:" & student.Grade)
' 删除学生
system.DeleteStudent("李四")
' 显示剩余学生信息(遍历)
For Each student In system.Students
Console.WriteLine("姓名:" & student.Name & " 年龄:" & student.Age & " 年级:" & student.Grade)
Next
End Sub
```
这是一个简单的学生管理系统代码示例,包含了学生类和学生管理系统类。主模块中创建一个学生管理系统对象,然后进行添加学生、查询学生、删除学生等操作,并对添加、查询和删除的结果进行输出显示。可以根据需要进行扩展和修改。
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)