📄 frmaddmarks.vb
字号:
Imports System.IO
Public Class frmAddMarks
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 txtStNo As System.Windows.Forms.TextBox
Friend WithEvents txtStName As System.Windows.Forms.TextBox
Friend WithEvents txtTXYL As System.Windows.Forms.TextBox
Friend WithEvents txtDZXL As System.Windows.Forms.TextBox
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents btnAdd As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.GroupBox1 = New System.Windows.Forms.GroupBox
Me.btnAdd = New System.Windows.Forms.Button
Me.Label4 = New System.Windows.Forms.Label
Me.Label3 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.Label1 = New System.Windows.Forms.Label
Me.txtDZXL = New System.Windows.Forms.TextBox
Me.txtTXYL = New System.Windows.Forms.TextBox
Me.txtStName = New System.Windows.Forms.TextBox
Me.txtStNo = New System.Windows.Forms.TextBox
Me.GroupBox1.SuspendLayout()
Me.SuspendLayout()
'
'GroupBox1
'
Me.GroupBox1.BackColor = System.Drawing.Color.FromArgb(CType(255, Byte), CType(192, Byte), CType(255, Byte))
Me.GroupBox1.Controls.Add(Me.btnAdd)
Me.GroupBox1.Controls.Add(Me.Label4)
Me.GroupBox1.Controls.Add(Me.Label3)
Me.GroupBox1.Controls.Add(Me.Label2)
Me.GroupBox1.Controls.Add(Me.Label1)
Me.GroupBox1.Controls.Add(Me.txtDZXL)
Me.GroupBox1.Controls.Add(Me.txtTXYL)
Me.GroupBox1.Controls.Add(Me.txtStName)
Me.GroupBox1.Controls.Add(Me.txtStNo)
Me.GroupBox1.Location = New System.Drawing.Point(8, 8)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(200, 256)
Me.GroupBox1.TabIndex = 0
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "添加学生成绩"
'
'btnAdd
'
Me.btnAdd.Location = New System.Drawing.Point(8, 216)
Me.btnAdd.Name = "btnAdd"
Me.btnAdd.Size = New System.Drawing.Size(48, 23)
Me.btnAdd.TabIndex = 8
Me.btnAdd.Text = "添加"
'
'Label4
'
Me.Label4.Location = New System.Drawing.Point(8, 168)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(56, 16)
Me.Label4.TabIndex = 7
Me.Label4.Text = "电子线路"
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(8, 128)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(56, 16)
Me.Label3.TabIndex = 6
Me.Label3.Text = "通信原理"
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(8, 72)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(64, 16)
Me.Label2.TabIndex = 5
Me.Label2.Text = "姓 名"
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(8, 28)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(56, 16)
Me.Label1.TabIndex = 4
Me.Label1.Text = "学 号"
'
'txtDZXL
'
Me.txtDZXL.Location = New System.Drawing.Point(72, 168)
Me.txtDZXL.Name = "txtDZXL"
Me.txtDZXL.TabIndex = 3
Me.txtDZXL.Text = ""
'
'txtTXYL
'
Me.txtTXYL.Location = New System.Drawing.Point(72, 120)
Me.txtTXYL.Name = "txtTXYL"
Me.txtTXYL.TabIndex = 2
Me.txtTXYL.Text = ""
'
'txtStName
'
Me.txtStName.Location = New System.Drawing.Point(72, 72)
Me.txtStName.Name = "txtStName"
Me.txtStName.TabIndex = 1
Me.txtStName.Text = ""
'
'txtStNo
'
Me.txtStNo.Location = New System.Drawing.Point(72, 24)
Me.txtStNo.Name = "txtStNo"
Me.txtStNo.TabIndex = 0
Me.txtStNo.Text = ""
'
'frmAddMarks
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.BackColor = System.Drawing.SystemColors.ActiveCaptionText
Me.ClientSize = New System.Drawing.Size(216, 270)
Me.Controls.Add(Me.GroupBox1)
Me.Name = "frmAddMarks"
Me.Text = "frmAddMarks"
Me.GroupBox1.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Dim strTemp As String '临时
Dim arrNo(8) As Char '学号为9位,如03051125,03-入学年份,05-所在学院代码,1-
strTemp = txtStNo.Text.Trim
If strTemp.Length <> 9 Then
MessageBox.Show("学号必须为9位!请重新输入")
Exit Sub
Else
strTemp.CopyTo(0, arrNo, 0, 9)
End If
Dim arrName(2) As Char '姓名不能超过3个字
strTemp = txtStName.Text.Trim
If strTemp.Length = 0 Then
MessageBox.Show("请输入姓名")
Exit Sub
ElseIf strTemp.Length <= 3 Then
strTemp.CopyTo(0, arrName, 0, strTemp.Length)
Else
strTemp.CopyTo(0, arrName, 0, 3) '超过3位,将被截去
End If
Dim i As Integer
For i = 0 To 2
If arrName(i) = Nothing Then
arrName(i) = ""
End If
Next
If txtTXYL.Text.Trim.Length = 0 OrElse txtDZXL.Text.Trim.Length = 0 Then
MessageBox.Show("请输入成绩")
Exit Sub
End If
Dim intTXYL As Integer = CInt(txtTXYL.Text)
Dim intDZXL As Integer = CInt(txtDZXL.Text)
Dim fsMarks As New FileStream(".\Marks.bin", FileMode.Append, FileAccess.Write)
Dim bwMarks As New BinaryWriter(fsMarks)
bwMarks.Write(arrNo)
bwMarks.Write(arrName)
bwMarks.Write(intTXYL)
bwMarks.Write(intDZXL)
bwMarks.Close()
MessageBox.Show("添加成功")
txtStNo.Text = ""
txtStName.Text = ""
txtTXYL.Text = ""
txtDZXL.Text = ""
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -