Public Class Form1
    '注意结构体在模块中进行定义
    Public Structure STUDENT
        Dim xh As String   '学号
        Dim xm As String   '姓名
        Dim xb As Boolean  '性别
        Dim cj As Integer  '成绩
    End Structure

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim stu(4) As STUDENT
        Dim i As Integer
        Dim strtitle As String
        Dim strinfo As String = ""
        For i = 0 To 4
            With stu(i)
                .xh = InputBox("请输入第" & Str(i + 1) & "个学生的学号：")
                .xm = InputBox("请输入第" & Str(i + 1) & "个学生的姓名：")
                .xb = InputBox("请输入第" & Str(i + 1) & "个学生的性别：")
                .cj = InputBox("请输入第" & Str(i + 1) & "个学生的成绩：")
                strinfo = strinfo & .xh & vbTab & .xm & vbTab & .xb & vbTab & .cj & vbCrLf  '格式化学生信息
            End With
        Next
        strtitle = "学号" & vbTab & "姓名" & vbTab & "性别" & vbTab & "成绩"       '格式化表头
        TextBox1.Text = strtitle & vbCrLf & strinfo
    End Sub
End Class
