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

📄 订饭2.3.frm

📁 vb的订饭系统对出学者有很大的帮助值得参考
💻 FRM
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form Form1 
   Caption         =   "订饭2.3"
   ClientHeight    =   9000
   ClientLeft      =   3540
   ClientTop       =   3255
   ClientWidth     =   11535
   LinkTopic       =   "Form1"
   Picture         =   "订饭2.3.frx":0000
   ScaleHeight     =   9000
   ScaleWidth      =   11535
   Begin MSComDlg.CommonDialog CommonDialog1 
      Left            =   5400
      Top             =   0
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin VB.ListBox List3 
      Height          =   7620
      ItemData        =   "订饭2.3.frx":18B9D
      Left            =   5880
      List            =   "订饭2.3.frx":18B9F
      TabIndex        =   11
      Top             =   360
      Width           =   5295
   End
   Begin VB.Frame Frame3 
      Caption         =   "改变主意"
      Height          =   1695
      Left            =   360
      TabIndex        =   2
      Top             =   6360
      Width           =   5055
      Begin VB.CommandButton Command7 
         Caption         =   "Command7"
         Height          =   495
         Left            =   480
         TabIndex        =   7
         Top             =   600
         Width           =   1455
      End
   End
   Begin VB.Frame Frame2 
      Caption         =   "请(双击)选择你想吃的套餐"
      Height          =   3495
      Left            =   360
      TabIndex        =   1
      Top             =   2520
      Width           =   5055
      Begin VB.TextBox Text2 
         Height          =   375
         Left            =   480
         TabIndex        =   10
         Top             =   720
         Width           =   1935
      End
      Begin VB.ListBox List2 
         Height          =   1140
         ItemData        =   "订饭2.3.frx":18BA1
         Left            =   480
         List            =   "订饭2.3.frx":18BA3
         TabIndex        =   9
         Top             =   1560
         Width           =   1935
      End
      Begin VB.CommandButton Command6 
         Caption         =   "Command6"
         Height          =   495
         Left            =   3360
         TabIndex        =   6
         Top             =   2160
         Width           =   1215
      End
      Begin VB.CommandButton Command5 
         Caption         =   "Command5"
         Height          =   495
         Left            =   3360
         TabIndex        =   5
         Top             =   720
         Width           =   1215
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "请(双击)选择你的姓名"
      Height          =   1815
      Left            =   360
      TabIndex        =   0
      Top             =   360
      Width           =   5055
      Begin VB.TextBox Text1 
         Height          =   375
         Left            =   3360
         TabIndex        =   8
         Top             =   360
         Width           =   1215
      End
      Begin VB.CommandButton Command1 
         Caption         =   "Command1"
         Height          =   495
         Left            =   3360
         TabIndex        =   4
         Top             =   960
         Width           =   1215
      End
      Begin VB.ListBox List1 
         Height          =   960
         ItemData        =   "订饭2.3.frx":18BA5
         Left            =   480
         List            =   "订饭2.3.frx":18BA7
         TabIndex        =   3
         Top             =   360
         Width           =   1935
      End
   End
   Begin VB.Menu getdata 
      Caption         =   "导入文件(&D)"
      Begin VB.Menu ming 
         Caption         =   "名单"
         Shortcut        =   ^M
      End
      Begin VB.Menu caidan 
         Caption         =   "菜单"
         Shortcut        =   ^C
      End
   End
   Begin VB.Menu keyinput 
      Caption         =   "键盘输入(&K)"
      Begin VB.Menu xing 
         Caption         =   "姓名"
         Shortcut        =   ^X
      End
      Begin VB.Menu caiming 
         Caption         =   "菜名"
         Shortcut        =   ^G
      End
   End
   Begin VB.Menu totalorder 
      Caption         =   "汇总(&Z)"
      Begin VB.Menu printorder 
         Caption         =   "打印"
         Shortcut        =   ^P
      End
      Begin VB.Menu outputorder 
         Caption         =   "输出"
         Shortcut        =   ^O
      End
   End
   Begin VB.Menu caihelp 
      Caption         =   "帮助(&H)"
      Begin VB.Menu chelp 
         Caption         =   "帮助"
      End
      Begin VB.Menu aboutthis 
         Caption         =   "关于"
      End
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Option Base 1
Dim mingzi(40) As String, sure(40) As String, price(20) As Integer    'mingzi(i)是记录名字的数组,sure(i)是记录菜名的数组,price(n)是记录菜价的数组
Public p As Integer, i As Integer, sp As Integer, j As Integer    'sp=sumprice,就是总金额.p是菜价

Private Sub aboutthis_Click()   '关于的内容
    MsgBox "订饭2.3版" & vbCrLf & "程序创意及制作:汤风华  版权所有  翻录不究" & vbCrLf & "感谢陶老师的指导和各位同学的建议"
End Sub

Private Sub caidan_Click()    '导入菜单
    CommonDialog1.FileName = ""
    CommonDialog1.Flags = cdlOFNFileMustExist
    CommonDialog1.Filter = "文本文档(*.txt)|*.txt"
    CommonDialog1.FilterIndex = 1
    CommonDialog1.DialogTitle = "打开菜单文件(*.txt)"
    CommonDialog1.Action = 1
    If CommonDialog1.FileName = "" Then
        MsgBox "没有选定文件", 21, "出错提示"
    Else
        Open CommonDialog1.FileName For Input As #2
        Dim menu As String, n As Integer
        n = 1
        Do While Not EOF(2)
        Input #2, menu, price(n)
        List2.AddItem menu
        n = n + 1
        Loop
        Close #2
    End If
End Sub

Private Sub caiming_Click()    '输入菜单并保存,以后可直接导入
    Dim g As Integer, b As Integer, wenti As String, cd(20) As String    'cd(b)是记录菜单的数组
    g = Val(InputBox("请输入品种数(阿拉伯数字):"))
    For b = 1 To g
        cd(b) = InputBox("请输入第" & b & "个套餐的名称,然后按Enter键:")
        List2.AddItem cd(b)
        price(b) = Val(InputBox("请输入第" & b & "个套餐的价格,然后按Enter键:"))
    Next b
    wenti = MsgBox("你想保存输入的菜单吗?", vbOKCancel + vbQuestion + vbDefaultButton1 + vbApplicationModal, "提示")
    If wenti = vbOK Then
        CommonDialog1.CancelError = False
        CommonDialog1.DefaultExt = "txt"
        CommonDialog1.FileName = ""
        CommonDialog1.Filter = "文本文档(*.txt)|*.txt"
        CommonDialog1.FilterIndex = 1
        CommonDialog1.DialogTitle = "保存菜单文件"
        CommonDialog1.Flags = 2050
        CommonDialog1.Action = 2
        If CommonDialog1.FileName = "" Then
            MsgBox "没有保存文件", 21, "出错提示"
        Else
            Open CommonDialog1.FileName For Output As #5
            For b = 1 To g
            Print #5, cd(b); ","; price(b)
            Next b
            Close #5
        End If
    End If
End Sub

Private Sub chelp_Click()   '帮助的内容
    MsgBox "一、导入文件必须为txt格式。" & vbCrLf & _
    "二、记录姓名的txt文件必须一个名字一行。" & vbCrLf & _
    "三、记录菜单的txt文件必须一个套餐一行。" & vbCrLf & _
    "四、套餐的名称后必须有价格,如:扬州炒饭,8" & vbCrLf & _
    "注意,当中的逗号必须是英文半角的。"
End Sub

Private Sub Command1_Click()    '取消错点的名字
    i = i - 1
    List1.Enabled = True
    Text1.Enabled = True
    Text1.Text = ""
    Command1.Enabled = False
    List2.Enabled = False
    Text2.Enabled = False
    List1.SetFocus
End Sub

Private Sub Command5_Click()    '点击确定,完成订饭
    sp = sp + p
    List3.Clear
    listprint
    List1.Enabled = True
    Text1.Enabled = True
    Text1.Text = ""
    Command5.Enabled = False
    Command6.Enabled = False
    Command7.Enabled = True
    Text2.Text = ""
    List1.SetFocus
End Sub

Private Sub Command6_Click()    '点击取消,订另一种饭,回到列表框2
    p = 0
    Command5.Enabled = False
    Command6.Enabled = False
    List2.Enabled = True
    Text2.Enabled = True
    Text2.Text = ""
    List2.SetFocus
End Sub

Private Sub Command7_Click()    '取消刚才的订单
    Dim answer As String
    answer = MsgBox("你确定吗?", vbOKCancel + vbQuestion + vbDefaultButton1 + vbApplicationModal, "提示")
    If answer = vbOK Then
        List3.Clear
        List3.AddItem mingzi(i) & "的订单取消。"
        i = i - 1
        sp = sp - p
        p = 0
        Command7.Enabled = False
        listprint
    End If
    List1.SetFocus
End Sub

Private Sub Form_Load()
    '按钮的名称
    Command1.Caption = "取消"
    Command5.Caption = "确定"
    Command6.Caption = "取消"
    Command7.Caption = "取消订单"
    '控件的背景色
    Text1.BackColor = vbYellow
    Text2.BackColor = vbYellow
    List1.BackColor = vbYellow
    List2.BackColor = vbYellow
    Frame1.BackColor = vbYellow
    Frame2.BackColor = vbYellow
    Frame3.BackColor = vbYellow
    List3.BackColor = vbYellow
    '初始化控件的可用属性,让控件一开始不可用
    Command1.Enabled = False
    Command5.Enabled = False
    Command6.Enabled = False
    Command7.Enabled = False
    List2.Enabled = False
    Text2.Enabled = False
End Sub

Private Sub List1_DblClick()    '双击确定自己的名字
    Text1.Text = List1.Text
    i = i + 1
    mingzi(i) = Text1.Text
    List1.Enabled = False
    Text1.Enabled = False
    Command1.Enabled = True
    Command7.Enabled = False
    List2.Enabled = True
    Text2.Enabled = True
    List2.SetFocus
End Sub

Private Sub List2_DblClick()    '双击选择套餐
    Dim m As Integer
    Text2.Text = List2.Text
    sure(i) = Text2.Text
    m = List2.ListIndex
    p = price(m + 1)
    Command1.Enabled = False
    Command5.Enabled = True
    Command6.Enabled = True
    List2.Enabled = False
    Text2.Enabled = False
    Command5.SetFocus
End Sub

Private Sub listprint()    '子过程,作用是打印名字和菜名,以简化代码
    For j = 1 To i
    List3.AddItem mingzi(j) & "        " & sure(j)
    Next j
End Sub

Private Sub ming_Click()    '导入人员名单
    CommonDialog1.FileName = ""
    CommonDialog1.Flags = cdlOFNFileMustExist
    CommonDialog1.Filter = "文本文档(*.txt)|*.txt"
    CommonDialog1.FilterIndex = 1
    CommonDialog1.DialogTitle = "打开姓名文件(*.txt)"
    CommonDialog1.Action = 1
    If CommonDialog1.FileName = "" Then
        MsgBox "没有选定文件", 21, "出错提示"
    Else
        Open CommonDialog1.FileName For Input As #1
        Dim xm As String
        Do While Not EOF(1)
        Line Input #1, xm
        List1.AddItem xm
        Loop
        Close #1
    End If
End Sub

Private Sub outputorder_Click()    '将订单输出到文件
    CommonDialog1.CancelError = False
    CommonDialog1.DefaultExt = "txt"
    CommonDialog1.FileName = ""
    CommonDialog1.Filter = "文本文档(*.txt)|*.txt"
    CommonDialog1.FilterIndex = 1
    CommonDialog1.DialogTitle = "保存订单文件"
    CommonDialog1.Flags = 2048
    CommonDialog1.Action = 2
    If CommonDialog1.FileName = "" Then
        MsgBox "没有保存文件", 21, "出错提示"
    Else
        Open CommonDialog1.FileName For Append As #3
        For j = 1 To i
        Print #3, mingzi(j), sure(j)
        Next j
        Print #3, "共有" & i & "人订饭,"; "总金额" & sp & "元。"
        Print #3, Date$, Time$
        Close #3
    End If
End Sub

Private Sub printorder_Click()    '打印出总人数和总金额
    List3.Clear
    listprint
    List3.AddItem "共有" & i & "人订饭," & "总金额" & sp & "元。"
    Command7.Enabled = False
End Sub

Private Sub xing_Click()    '输入人员名单并保存,以后可直接导入
    Dim x As Integer, a As Integer, wenti As String, xm(40) As String    'xm(a)是记录姓名的数组
    x = Val(InputBox("请输入人数(阿拉伯数字):"))
    For a = 1 To x
        xm(a) = InputBox("请输入第" & a & "个人的姓名,然后按Enter键:")
        List1.AddItem xm(a)
    Next a
    wenti = MsgBox("你想保存输入的姓名吗?", vbOKCancel + vbQuestion + vbDefaultButton1 + vbApplicationModal, "提示")
    If wenti = vbOK Then
        CommonDialog1.CancelError = False
        CommonDialog1.DefaultExt = "txt"
        CommonDialog1.FileName = ""
        CommonDialog1.Filter = "文本文档(*.txt)|*.txt"
        CommonDialog1.FilterIndex = 1
        CommonDialog1.DialogTitle = "保存姓名文件"
        CommonDialog1.Flags = 2050
        CommonDialog1.Action = 2
        If CommonDialog1.FileName = "" Then
            MsgBox "没有保存文件", 21, "出错提示"
        Else
            Open CommonDialog1.FileName For Output As #4
            For a = 1 To x
            Print #4, xm(a)
            Next a
            Close #4
        End If
    End If
End Sub

⌨️ 快捷键说明

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