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

📄 form1.vb

📁 一些VB中数组运用的例子
💻 VB
字号:
Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    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
    Friend WithEvents lblHead As System.Windows.Forms.Label
    Friend WithEvents lblName As System.Windows.Forms.Label
    Friend WithEvents txtScore As System.Windows.Forms.TextBox
    Friend WithEvents btnOp As System.Windows.Forms.Button
    Friend WithEvents btnEnd As System.Windows.Forms.Button

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.Container

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.btnEnd = New System.Windows.Forms.Button
        Me.lblName = New System.Windows.Forms.Label
        Me.txtScore = New System.Windows.Forms.TextBox
        Me.btnOp = New System.Windows.Forms.Button
        Me.lblHead = New System.Windows.Forms.Label
        Me.SuspendLayout()
        '
        'btnEnd
        '
        Me.btnEnd.Font = New System.Drawing.Font("Microsoft Sans Serif", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
        Me.btnEnd.Location = New System.Drawing.Point(163, 105)
        Me.btnEnd.Name = "btnEnd"
        Me.btnEnd.Size = New System.Drawing.Size(77, 29)
        Me.btnEnd.TabIndex = 4
        Me.btnEnd.Text = "退出"
        '
        'lblName
        '
        Me.lblName.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
        Me.lblName.Location = New System.Drawing.Point(48, 67)
        Me.lblName.Name = "lblName"
        Me.lblName.Size = New System.Drawing.Size(77, 23)
        Me.lblName.TabIndex = 1
        Me.lblName.Text = "Label2"
        '
        'txtScore
        '
        Me.txtScore.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
        Me.txtScore.Location = New System.Drawing.Point(163, 60)
        Me.txtScore.Name = "txtScore"
        Me.txtScore.Size = New System.Drawing.Size(77, 26)
        Me.txtScore.TabIndex = 2
        Me.txtScore.Text = ""
        '
        'btnOp
        '
        Me.btnOp.Font = New System.Drawing.Font("Microsoft Sans Serif", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
        Me.btnOp.Location = New System.Drawing.Point(38, 105)
        Me.btnOp.Name = "btnOp"
        Me.btnOp.Size = New System.Drawing.Size(77, 29)
        Me.btnOp.TabIndex = 3
        Me.btnOp.Text = "登录"
        '
        'lblHead
        '
        Me.lblHead.Font = New System.Drawing.Font("Microsoft Sans Serif", 15.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
        Me.lblHead.Location = New System.Drawing.Point(67, 15)
        Me.lblHead.Name = "lblHead"
        Me.lblHead.Size = New System.Drawing.Size(144, 30)
        Me.lblHead.TabIndex = 0
        Me.lblHead.Text = "成绩登记表"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(278, 146)
        Me.Controls.Add(Me.btnEnd)
        Me.Controls.Add(Me.btnOp)
        Me.Controls.Add(Me.txtScore)
        Me.Controls.Add(Me.lblName)
        Me.Controls.Add(Me.lblHead)
        Me.Name = "Form1"
        Me.Text = "f10_1_1"
        Me.ResumeLayout(False)

    End Sub

#End Region
    '************** f10_1_1 **************
    Dim s_name() As String = {"张三", "李四", "王五", "周六", "孙七"}
    Dim s_score(4) As Single
    Dim no As Integer = 0

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        lblName.Text = s_name(no)
    End Sub

    Private Sub btnOp_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnOp.Click
        Dim score, sum As Single
        s_score(no) = txtScore.Text           '登录分数
        no += 1                               '索引指针加 1
        If no = 5 Then
            For Each score In s_score
                sum += score
            Next
            lblName.Text = "平均"
            txtScore.Text = sum / no
            btnOp.Visible = False               '隐藏 btnOp
            btnEnd.Focus()                      'btnEnd 取得焦点
            Exit Sub
        End If
        lblName.Text = s_name(no)               '出现下一位学生姓名
        txtScore.Text = ""
        txtScore.Focus()                        'txtScore 取得焦点
    End Sub

    Private Sub btnEnd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnEnd.Click
        End
    End Sub
End Class

⌨️ 快捷键说明

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