📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3855
ClientLeft = 60
ClientTop = 465
ClientWidth = 6765
LinkTopic = "Form1"
ScaleHeight = 3855
ScaleWidth = 6765
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command3
Caption = "退出"
Height = 375
Left = 3240
TabIndex = 9
Top = 3120
Width = 735
End
Begin VB.CommandButton Command2
Caption = "总清"
Height = 375
Left = 2160
TabIndex = 8
Top = 3120
Width = 735
End
Begin VB.CommandButton Command1
Caption = "小计"
Height = 375
Left = 1080
TabIndex = 7
Top = 3120
Width = 735
End
Begin VB.ListBox List1
Height = 2040
Left = 2280
TabIndex = 6
Top = 480
Width = 4095
End
Begin VB.TextBox Text3
Height = 495
Left = 1200
TabIndex = 5
Top = 2160
Width = 975
End
Begin VB.TextBox Text2
Height = 495
Left = 1200
TabIndex = 4
Top = 1320
Width = 975
End
Begin VB.TextBox Text1
Height = 495
Left = 1200
TabIndex = 3
Top = 480
Width = 975
End
Begin VB.Label Label3
Caption = "总金额"
Height = 495
Left = 240
TabIndex = 2
Top = 2160
Width = 735
End
Begin VB.Label Label2
Caption = "数量"
Height = 495
Left = 240
TabIndex = 1
Top = 1320
Width = 735
End
Begin VB.Label Label1
Caption = "商品代码"
Height = 495
Left = 240
TabIndex = 0
Top = 480
Width = 855
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim Id() As String * 8, Price() As Single
Dim BName() As String * 10, Ide As String * 8, Num As Integer
Dim J As Integer, sum As Single
Private Sub Command1_Click()
Text1.Text = ""
Text2.Text = ""
List1.Clear
Text3.Text = ""
List1.AddItem "商品名 数量 单价 小计"
Text1.SetFocus
End Sub
Private Sub Command2_Click()
Dim i As Integer, t As Long
Dim Total As Single
Ide = Text1.Text
For i = 1 To UBound(Id)
If Ide = Id(i) Then Exit For
Next i
If i > UBound(Id) Then
t = MsgBox("代码错误!重输!", , "程序示例")
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
Exit Sub
Else
J = i
End If
Num = Val(Text2.Text)
Total = Price(J) * Num
List1.AddItem BName(J) & CStr(Num) & "" & Price(J) & "" & Total & Chr(13)
sum = sum + Total
Text3.Text = sum
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
End Sub
Private Sub Command3_Click()
Unload Me
End
End Sub
Private Sub Form_Load()
Dim k As Integer, Df As String
Df = App.Path & "\" & "data.txt"
Open Df For Input As #11
k = 1
Do While Not EOF(11)
ReDim Preserve BName(k), Id(k), Price(k)
Input #11, BName(k), Id(k), Price(k)
k = k + 1
Loop
Close (11)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -