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

📄 form1.vb

📁 visual basic课程设计案例精编
💻 VB
字号:
Public Class Form1
    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 BtSave As System.Windows.Forms.Button
    Friend WithEvents Label11 As System.Windows.Forms.Label
    Friend WithEvents Label9 As System.Windows.Forms.Label
    Friend WithEvents Label8 As System.Windows.Forms.Label
    Friend WithEvents Label7 As System.Windows.Forms.Label
    Friend WithEvents Label6 As System.Windows.Forms.Label
    Friend WithEvents Label5 As System.Windows.Forms.Label
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents txtSpecial As System.Windows.Forms.TextBox
    Friend WithEvents txtAddress As System.Windows.Forms.TextBox
    Friend WithEvents txtMovement As System.Windows.Forms.TextBox
    Friend WithEvents txtPhone As System.Windows.Forms.TextBox
    Friend WithEvents txtCount As System.Windows.Forms.TextBox
    Friend WithEvents txtName As System.Windows.Forms.TextBox
    Friend WithEvents CBdish As System.Windows.Forms.ComboBox
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents BtClose As System.Windows.Forms.Button
    Friend WithEvents SaveFileDialog1 As System.Windows.Forms.SaveFileDialog
    Friend WithEvents TxtCell As System.Windows.Forms.TextBox
    Friend WithEvents txtEmail As System.Windows.Forms.TextBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.BtSave = New System.Windows.Forms.Button
        Me.txtSpecial = New System.Windows.Forms.TextBox
        Me.txtAddress = New System.Windows.Forms.TextBox
        Me.txtEmail = New System.Windows.Forms.TextBox
        Me.txtMovement = New System.Windows.Forms.TextBox
        Me.txtPhone = New System.Windows.Forms.TextBox
        Me.txtCount = New System.Windows.Forms.TextBox
        Me.txtName = New System.Windows.Forms.TextBox
        Me.Label11 = New System.Windows.Forms.Label
        Me.Label9 = New System.Windows.Forms.Label
        Me.Label8 = New System.Windows.Forms.Label
        Me.Label7 = New System.Windows.Forms.Label
        Me.Label6 = New System.Windows.Forms.Label
        Me.Label5 = New System.Windows.Forms.Label
        Me.Label4 = New System.Windows.Forms.Label
        Me.Label2 = New System.Windows.Forms.Label
        Me.CBdish = New System.Windows.Forms.ComboBox
        Me.TxtCell = New System.Windows.Forms.TextBox
        Me.Label1 = New System.Windows.Forms.Label
        Me.BtClose = New System.Windows.Forms.Button
        Me.SaveFileDialog1 = New System.Windows.Forms.SaveFileDialog
        Me.SuspendLayout()
        '
        'BtSave
        '
        Me.BtSave.Location = New System.Drawing.Point(152, 312)
        Me.BtSave.Name = "BtSave"
        Me.BtSave.Size = New System.Drawing.Size(88, 24)
        Me.BtSave.TabIndex = 49
        Me.BtSave.Text = "发送订单"
        '
        'txtSpecial
        '
        Me.txtSpecial.Location = New System.Drawing.Point(136, 272)
        Me.txtSpecial.Multiline = True
        Me.txtSpecial.Name = "txtSpecial"
        Me.txtSpecial.Size = New System.Drawing.Size(344, 21)
        Me.txtSpecial.TabIndex = 44
        Me.txtSpecial.Text = ""
        '
        'txtAddress
        '
        Me.txtAddress.Location = New System.Drawing.Point(136, 176)
        Me.txtAddress.Name = "txtAddress"
        Me.txtAddress.Size = New System.Drawing.Size(344, 21)
        Me.txtAddress.TabIndex = 42
        Me.txtAddress.Text = ""
        '
        'txtEmail
        '
        Me.txtEmail.Location = New System.Drawing.Point(136, 128)
        Me.txtEmail.Name = "txtEmail"
        Me.txtEmail.Size = New System.Drawing.Size(112, 21)
        Me.txtEmail.TabIndex = 47
        Me.txtEmail.Text = ""
        '
        'txtMovement
        '
        Me.txtMovement.Location = New System.Drawing.Point(136, 224)
        Me.txtMovement.Name = "txtMovement"
        Me.txtMovement.Size = New System.Drawing.Size(344, 21)
        Me.txtMovement.TabIndex = 48
        Me.txtMovement.Text = ""
        '
        'txtPhone
        '
        Me.txtPhone.Location = New System.Drawing.Point(384, 80)
        Me.txtPhone.Name = "txtPhone"
        Me.txtPhone.Size = New System.Drawing.Size(96, 21)
        Me.txtPhone.TabIndex = 45
        Me.txtPhone.Text = ""
        '
        'txtCount
        '
        Me.txtCount.Location = New System.Drawing.Point(384, 32)
        Me.txtCount.Name = "txtCount"
        Me.txtCount.Size = New System.Drawing.Size(96, 21)
        Me.txtCount.TabIndex = 46
        Me.txtCount.Text = ""
        '
        'txtName
        '
        Me.txtName.Location = New System.Drawing.Point(136, 80)
        Me.txtName.Name = "txtName"
        Me.txtName.Size = New System.Drawing.Size(112, 21)
        Me.txtName.TabIndex = 40
        Me.txtName.Text = ""
        '
        'Label11
        '
        Me.Label11.Location = New System.Drawing.Point(40, 272)
        Me.Label11.Name = "Label11"
        Me.Label11.Size = New System.Drawing.Size(64, 18)
        Me.Label11.TabIndex = 34
        Me.Label11.Text = "特殊要求:"
        '
        'Label9
        '
        Me.Label9.Location = New System.Drawing.Point(40, 176)
        Me.Label9.Name = "Label9"
        Me.Label9.Size = New System.Drawing.Size(64, 18)
        Me.Label9.TabIndex = 31
        Me.Label9.Text = "详细地址:"
        '
        'Label8
        '
        Me.Label8.Location = New System.Drawing.Point(296, 80)
        Me.Label8.Name = "Label8"
        Me.Label8.Size = New System.Drawing.Size(64, 18)
        Me.Label8.TabIndex = 32
        Me.Label8.Text = "联系电话:"
        '
        'Label7
        '
        Me.Label7.Location = New System.Drawing.Point(40, 128)
        Me.Label7.Name = "Label7"
        Me.Label7.Size = New System.Drawing.Size(64, 18)
        Me.Label7.TabIndex = 35
        Me.Label7.Text = "Email:"
        '
        'Label6
        '
        Me.Label6.Location = New System.Drawing.Point(40, 224)
        Me.Label6.Name = "Label6"
        Me.Label6.Size = New System.Drawing.Size(64, 18)
        Me.Label6.TabIndex = 38
        Me.Label6.Text = "送货方式:"
        '
        'Label5
        '
        Me.Label5.Location = New System.Drawing.Point(296, 32)
        Me.Label5.Name = "Label5"
        Me.Label5.Size = New System.Drawing.Size(64, 18)
        Me.Label5.TabIndex = 39
        Me.Label5.Text = "数量:"
        '
        'Label4
        '
        Me.Label4.Location = New System.Drawing.Point(40, 32)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(72, 18)
        Me.Label4.TabIndex = 37
        Me.Label4.Text = "菜肴名称"
        '
        'Label2
        '
        Me.Label2.Location = New System.Drawing.Point(40, 80)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(64, 18)
        Me.Label2.TabIndex = 36
        Me.Label2.Text = "客户姓名:"
        '
        'CBdish
        '
        Me.CBdish.Items.AddRange(New Object() {"宫爆鸡丁", "鱼香肉丝", "红烧茄子", "剁椒鸭粒"})
        Me.CBdish.Location = New System.Drawing.Point(136, 32)
        Me.CBdish.Name = "CBdish"
        Me.CBdish.Size = New System.Drawing.Size(112, 20)
        Me.CBdish.TabIndex = 50
        '
        'TxtCell
        '
        Me.TxtCell.Location = New System.Drawing.Point(384, 128)
        Me.TxtCell.Name = "TxtCell"
        Me.TxtCell.Size = New System.Drawing.Size(96, 21)
        Me.TxtCell.TabIndex = 52
        Me.TxtCell.Text = ""
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(296, 128)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(64, 18)
        Me.Label1.TabIndex = 51
        Me.Label1.Text = "手机:"
        '
        'BtClose
        '
        Me.BtClose.Location = New System.Drawing.Point(312, 312)
        Me.BtClose.Name = "BtClose"
        Me.BtClose.Size = New System.Drawing.Size(88, 24)
        Me.BtClose.TabIndex = 53
        Me.BtClose.Text = "关闭"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(528, 350)
        Me.Controls.Add(Me.BtClose)
        Me.Controls.Add(Me.TxtCell)
        Me.Controls.Add(Me.Label1)
        Me.Controls.Add(Me.CBdish)
        Me.Controls.Add(Me.BtSave)
        Me.Controls.Add(Me.txtSpecial)
        Me.Controls.Add(Me.txtAddress)
        Me.Controls.Add(Me.txtEmail)
        Me.Controls.Add(Me.txtMovement)
        Me.Controls.Add(Me.txtPhone)
        Me.Controls.Add(Me.txtCount)
        Me.Controls.Add(Me.txtName)
        Me.Controls.Add(Me.Label11)
        Me.Controls.Add(Me.Label9)
        Me.Controls.Add(Me.Label8)
        Me.Controls.Add(Me.Label7)
        Me.Controls.Add(Me.Label6)
        Me.Controls.Add(Me.Label5)
        Me.Controls.Add(Me.Label4)
        Me.Controls.Add(Me.Label2)
        Me.Name = "Form1"
        Me.Text = "订单发送程序"
        Me.ResumeLayout(False)

    End Sub

#End Region


    Public Sub OrderFromForm(ByVal Order As Order)
        ' 拷贝文本框的内容
        Order.Dish = CBdish.Text
        Order.DishCount = txtCount.Text
        Order.Name = txtName.Text
        Order.Phone = txtPhone.Text
        Order.Email = txtEmail.Text
        Order.Cell = TxtCell.Text
        Order.Address = txtAddress.Text
        Order.Movement = txtMovement.Text
        Order.Special = txtSpecial.Text
    End Sub
    Public ReadOnly Property DataFilename() As String
        Get
            Dim folder As String
            Return "C:\Order\Order.xml"
            '返回要保存的文件名
        End Get
    End Property

    Private Sub BtClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtClose.Click
        Me.Dispose()
    End Sub

    Private Sub BtSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtSave.Click
        Dim Order As New Order
        '创建一个订单对象
        OrderFromForm(Order)
        '将条目信息拷贝到订单对象中
        Dim filename As String = DataFilename
        Order.SaveXmlFile(filename)
        '保存订单
        MsgBox("订单已提交" & filename)
        '告知客户
    End Sub


End Class

⌨️ 快捷键说明

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