form1.vb

来自「Visual Basic .NET程序设计教程源代码」· VB 代码 · 共 84 行

VB
84
字号
Public Class Form1
    Inherits System.Windows.Forms.Form
    Const MAX_MEM = 2
    Private Structure mail
        Public num As Short
        Public name As String
        Public title As String
        Public addr As String
        Public zip As Integer
        Public tel As String
    End Structure
    Dim list(MAX_MEM) As mail
#Region " Windows 窗体设计器生成的代码 "

    Public Sub New()
        MyBase.New()

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

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

    End Sub

    '窗体重写处置以清理组件列表。
    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 窗体设计器修改此过程。
    '不要使用代码编辑器修改它。
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(292, 273)
        Me.Name = "Form1"
        Me.Text = "Form1"

    End Sub

#End Region

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim i As Short
        '从键盘上一次录入每个会员的各数据项的数据
        For i = 0 To MAX_MEM
            list(i).num = InputBox("请输入编号")
            list(i).name = InputBox("请输入姓名")
            list(i).title = InputBox("请输入职称")
            list(i).addr = InputBox("请输入地址")
            list(i).zip = InputBox("请输入邮编")
            list(i).tel = InputBox("请输入电话号码")
        Next i
        '输出数据
        Debug.WriteLine("")
        Debug.Write("===============================================")
        Debug.WriteLine("===============")
        Debug.Write("编号      姓名      职称      地址")
        Debug.WriteLine("      邮政编码      电话号码")
        '依次显示已登录的数据元素的各成员值
        Dim spa As String = "    "
        For i = 0 To MAX_MEM
            Debug.Write("===============================================")
            Debug.WriteLine("===============")
            Debug.Write(" " & list(i).num & spa & list(i).name)
            Debug.Write(spa & list(i).title & spa & list(i).addr)
            Debug.WriteLine("    " & list(i).zip & spa & "    " & list(i).tel)
        Next
        Debug.Write("===============================================")
        Debug.WriteLine("===============")
    End Sub
End Class

⌨️ 快捷键说明

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