⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmsearchmarks.vb

📁 这是一个经典的学生管理的例程序欢迎使用偶
💻 VB
字号:

Imports System.IO
Public Class frmSearchMarks
    Inherits System.Windows.Forms.Form

#Region " Windows 窗体设计器生成的代码 "

    Public Sub New()
        MyBase.New()

        '该调用是 Windows 窗体设计器所必需的。
        InitializeComponent()

        '在 InitializeComponent() 调用之后添加任何初始化

    End Sub

    '窗体重写 dispose 以清理组件列表。
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Windows 窗体设计器所必需的
    Private components As System.ComponentModel.IContainer

    '注意: 以下过程是 Windows 窗体设计器所必需的
    '可以使用 Windows 窗体设计器修改此过程。
    '不要使用代码编辑器修改它。
    Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
    Friend WithEvents txtShowMarks As System.Windows.Forms.TextBox
    Friend WithEvents txtStNoIn As System.Windows.Forms.TextBox
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents btnSearch As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.GroupBox1 = New System.Windows.Forms.GroupBox
        Me.txtShowMarks = New System.Windows.Forms.TextBox
        Me.txtStNoIn = New System.Windows.Forms.TextBox
        Me.Label1 = New System.Windows.Forms.Label
        Me.btnSearch = New System.Windows.Forms.Button
        Me.GroupBox1.SuspendLayout()
        Me.SuspendLayout()
        '
        'GroupBox1
        '
        Me.GroupBox1.BackColor = System.Drawing.Color.Transparent
        Me.GroupBox1.Controls.Add(Me.txtShowMarks)
        Me.GroupBox1.Location = New System.Drawing.Point(16, 16)
        Me.GroupBox1.Name = "GroupBox1"
        Me.GroupBox1.Size = New System.Drawing.Size(248, 152)
        Me.GroupBox1.TabIndex = 0
        Me.GroupBox1.TabStop = False
        Me.GroupBox1.Text = "成绩查询结果"
        '
        'txtShowMarks
        '
        Me.txtShowMarks.BackColor = System.Drawing.Color.DeepSkyBlue
        Me.txtShowMarks.Dock = System.Windows.Forms.DockStyle.Fill
        Me.txtShowMarks.ForeColor = System.Drawing.SystemColors.Window
        Me.txtShowMarks.Location = New System.Drawing.Point(3, 17)
        Me.txtShowMarks.Multiline = True
        Me.txtShowMarks.Name = "txtShowMarks"
        Me.txtShowMarks.ReadOnly = True
        Me.txtShowMarks.Size = New System.Drawing.Size(242, 132)
        Me.txtShowMarks.TabIndex = 0
        Me.txtShowMarks.Text = ""
        '
        'txtStNoIn
        '
        Me.txtStNoIn.Location = New System.Drawing.Point(24, 224)
        Me.txtStNoIn.Name = "txtStNoIn"
        Me.txtStNoIn.Size = New System.Drawing.Size(112, 21)
        Me.txtStNoIn.TabIndex = 1
        Me.txtStNoIn.Text = ""
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(24, 192)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(128, 23)
        Me.Label1.TabIndex = 2
        Me.Label1.Text = "请输入要查询的学号"
        '
        'btnSearch
        '
        Me.btnSearch.Location = New System.Drawing.Point(192, 224)
        Me.btnSearch.Name = "btnSearch"
        Me.btnSearch.Size = New System.Drawing.Size(56, 23)
        Me.btnSearch.TabIndex = 3
        Me.btnSearch.Text = "查询"
        '
        'frmSearchMarks
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.BackColor = System.Drawing.Color.FromArgb(CType(255, Byte), CType(192, Byte), CType(255, Byte))
        Me.ClientSize = New System.Drawing.Size(280, 270)
        Me.Controls.Add(Me.btnSearch)
        Me.Controls.Add(Me.Label1)
        Me.Controls.Add(Me.txtStNoIn)
        Me.Controls.Add(Me.GroupBox1)
        Me.Name = "frmSearchMarks"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "frmSearchMarks"
        Me.GroupBox1.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
        txtShowMarks.Clear()
        Dim fsMarks As Filestream
        Try
            fsMarks = New FileStream(".\Marks.bin", FileMode.Open, FileAccess.Read)
        Catch ex As Exception
            MessageBox.Show(ex.ToString)
        End Try

        Dim brMarks As New BinaryReader(fsMarks)

        Dim arrNoRd(8) As Char
        Dim arrName(2) As Char
        Dim intTXYL As Integer
        Dim intDZXL As Integer
        Dim strTemp As String
        Dim arrNoIn(8) As Char

        Dim boolEqual As Boolean

        While brMarks.PeekChar > -1
            arrNoRd = brMarks.ReadChars(9)
            arrName = brMarks.ReadChars(3)
            intTXYL = brMarks.ReadInt32
            intDZXL = brMarks.ReadInt32

            strTemp = txtStNoIn.Text.Trim
            If strTemp.Length < 9 Then
                MessageBox.Show("学号必须为9位!请重新输入")
                Exit Sub
            Else
                strTemp.CopyTo(0, arrNoIn, 0, 9)
            End If

            Dim i As Integer
            boolEqual = True
            For i = 0 To 8
                If arrNoIn(i) <> arrNoRd(i) Then
                    boolEqual = False
                    Exit For
                End If
            Next

            If boolEqual Then
                txtShowMarks.Clear()
                txtShowMarks.Text += "学号:"
                For i = 0 To 8
                    txtShowMarks.Text += arrNoRd(i)
                Next
                txtShowMarks.Text += vbCrLf + "姓名:"
                For i = 0 To 2
                    txtShowMarks.Text += arrName(i)
                Next
                txtShowMarks.Text += vbCrLf + "通信原理:" + intTXYL.ToString
                txtShowMarks.Text += vbCrLf + "电子线路:" + intDZXL.ToString
                txtShowMarks.Text += vbCrLf

                Exit While '查询到符合的学号后立即退出循环
            End If

        End While

        '如果没有符合的记录,出现提示!
        If Not boolEqual Then
            MessageBox.Show("查无此学号")
        End If

        brMarks.Close()
    End Sub

End Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -