VB新建一个工程,完成“点餐”程序的设计。具体要求如下:

VB新建一个工程,完成“点餐”程序的设计。具体要求如下:,第1张

VERSION 5.00

Begin VB.Form Form1

Caption = "点餐旦高中"

ClientHeight= 6765

ClientLeft = 60

ClientTop = 450

ClientWidth = 8235

LinkTopic = "Form1"

ScaleHeight = 6765

ScaleWidth = 8235

StartUpPosition = 3 '窗口缺省

Begin VB.CommandButton Command1

Caption = "点餐"

Default = -1 'True

Height = 495

Left= 3270

TabIndex= 8

Top = 6000

Width = 1695

End

Begin VB.Frame Frame1

Caption = "点餐"

Height = 5415

Left= 210

TabIndex= 0

Top = 360

Width = 7815

Begin VB.TextBox Text1

Enabled = 0 '模山False

Height = 270

Index = 2

Left= 5520

TabIndex= 7

Top = 3472

Width = 1215

End

Begin VB.TextBox Text1

Height = 270

Index = 1

Left= 5520

TabIndex= 6

Top = 2632

Width = 1215

End

Begin VB.TextBox Text1

Enabled = 0 'False

Height = 270

Index = 0

Left= 5520

TabIndex= 5

Top = 1792

Width = 1215

End

Begin VB.CheckBox Check1

Caption = "标准套餐念陪18元"

Height = 255

Index = 1

Left= 210

TabIndex= 3

Top = 2640

Width = 1575

End

Begin VB.CheckBox Check1

Caption = "儿童套餐13元"

Height = 255

Index = 0

Left= 210

TabIndex= 2

Top = 1800

Width = 1575

End

Begin VB.CheckBox Check1

Caption = "商务套餐25元"

Height = 255

Index = 2

Left= 210

TabIndex= 1

Top = 3480

Width = 1575

End

Begin VB.Label Label1

Caption = "份数"

BeginProperty Font

Name= "黑体"

Size= 21.75

Charset = 134

Weight = 400

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

Height = 495

Left= 5640

TabIndex= 4

Top = 840

Width = 975

End

End

End

Attribute VB_Name = "Form1"

Attribute VB_GlobalNameSpace = False

Attribute VB_Creatable = False

Attribute VB_PredeclaredId = True

Attribute VB_Exposed = False

Private Sub Check1_Click(Index As Integer)

If Check1(Index).Value = 1 Then

Text1(Index).Enabled = True

Text1(Index).SetFocus

Else

Text1(Index).Text = ""

Text1(Index).Enabled = False

End If

End Sub

Private Sub Command1_Click()

Dim num As Integer

num = Val(Text1(0)) * 13 + Val(Text1(1)) * 18 + Val(Text1(2)) * 25

MsgBox "总价是" + Str(num)

End Sub

Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)

If KeyAscii >= 33 Then

If KeyAscii <= vbKey9 And KeyAscii >= vbKey0 Then

Else

KeyAscii = 0

End If

End If

End Sub

Private Sub Check1_Click()

If Check1.Value = 1 Then

Text1.Enabled = True

Else

Text1.Enabled = False

Text1.Text = ""

End If

End Sub

Private Sub Check2_Click()

If Check2.Value = 1 Then

Text2.Enabled = True

Else

Text2.Enabled = False

Text2.Text = ""

End If

End Sub

Private Sub Check3_Click()

If Check3.Value = 1 Then

Text3.Enabled = True

Else

Text3.Enabled = False

Text3.Text = ""

End If

End Sub

Private Sub Command1_Click()

Dim a As Integer, b As Integer, c As Integer, sum As Integer

a = Val(Text1.Text)

b = Val(Text2.Text)

c = Val(Text3.Text)

sum = a * 套餐一的价格 + b * 套餐二的价格 + c * 套餐三的价格

MsgBox "您点的套餐是:"亮锋 &vbCrLf &"套餐一" &Val(Text1) &"个" &vbCrLf &"套餐二" &Val(Text2) &"个" &vbCrLf &"套餐三" &Val(Text3) &"个" &vbCrLf &"共计"弊察 &sum &"元"

End Sub

Private Sub Form_Load()

Me.Caption = "点餐"

Command1.Caption = "确定"

Check1.Caption = "套餐一"

Check2.Caption = "套餐二"

Check3.Caption = "套餐三"

Text1.Text = ""

Text2.Text = ""

Text3.Text = ""

Text1.Enabled = False

Text2.Enabled = False

Text3.Enabled = False

End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)

If KeyAscii <>8 Then

If KeyAscii <Asc("0") Or KeyAscii >Asc("9") Then

MsgBox "请输入数字!"

KeyAscii = 0

End If

End If

End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)

If KeyAscii <>8 Then

If KeyAscii <Asc("0") Or KeyAscii >Asc("9") Then

MsgBox "请输入数字租键茄!"

KeyAscii = 0

End If

End If

End Sub

Private Sub Text3_KeyPress(KeyAscii As Integer)

If KeyAscii <>8 Then

If KeyAscii <Asc("0") Or KeyAscii >Asc("9") Then

MsgBox "请输入数字!"

KeyAscii = 0

End If

End If

End Sub

模块,流程....

然后

依照段型纤规划,

后台mssql2000或者msaccess做数据库,建些握仿表,

前台用vb.

窗体如图

属性设置:

form1-caption:顾客点菜单

list1:multiselect=2\style=0

list2:multiselect=0\style=1

command1:caption=添加

command2=caption=删除

lable1:caption=饭店菜谱

lable2:caption=顾客点菜

代码:

Private

Sub

Form_Load()

List1.AddItem

"*******"

'以下格式相同(*表示菜名)

End

Sub

Private

Sub

Command1_Click()

Dim

i%

'定义循环变量

For

i

=

List1.ListCount

-

1

To

0

Step

-1

If

List1.Selected(i)

Then

'判断是否被选中

List2.AddItem

List1.List(i)

'在list2中租山添加list1中被选中的

List1.RemoveItem

i

End

If

Next

i

End

Sub

Private

Sub

Command2_Click()

Dim

i%

For

i

=

List2.ListCount

-

1

To

0

Step

-1

If

List2.Selected(i)

Then

List1.AddItem

List2.List(i)

List2.RemoveItem

i

'从List2中删除此选中项

End

If

Next

i

End

Sub


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/12466638.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-23
下一篇2023-05-23

发表评论

登录后才能评论

评论列表(0条)

    保存