📄 例2-32.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.PictureBox Picture1
Height = 495
Left = 1080
ScaleHeight = 435
ScaleWidth = 2235
TabIndex = 9
Top = 2520
Width = 2295
End
Begin VB.CommandButton Command3
Caption = "统计"
Height = 495
Left = 3360
TabIndex = 8
Top = 1800
Width = 1095
End
Begin VB.CommandButton Command2
Caption = "插入"
Height = 495
Left = 1920
TabIndex = 7
Top = 1800
Width = 1095
End
Begin VB.CommandButton Command1
Caption = "追加"
Height = 495
Left = 360
TabIndex = 6
Top = 1800
Width = 1095
End
Begin VB.TextBox Text3
Height = 495
Left = 3360
TabIndex = 5
Top = 960
Width = 855
End
Begin VB.TextBox Text2
Height = 495
Left = 1920
TabIndex = 4
Top = 960
Width = 855
End
Begin VB.TextBox Text1
Height = 495
Left = 360
TabIndex = 3
Top = 960
Width = 855
End
Begin VB.Label Label3
Caption = "工资"
Height = 375
Left = 3360
TabIndex = 2
Top = 360
Width = 735
End
Begin VB.Label Label2
Caption = "职称"
Height = 495
Left = 1920
TabIndex = 1
Top = 360
Width = 855
End
Begin VB.Label Label1
Caption = "姓名"
Height = 375
Left = 480
TabIndex = 0
Top = 360
Width = 735
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Base 1
Dim empwage() As stremployee, intcurr As Integer, i As Integer, sum As Integer
'事件代码:
Private Sub Command1_Click() '追加事件过程
If Text1 <> "" Then
i = i + 1 '数组元素增加1个
ReDim Preserve empwage(i) '重定义数组,保持原数据不变
With empwage(i)
.name = Text1: .title = Text2: .wage = Val(Text3)
End With
Text1 = "": Text2 = "": Text3 = ""
Else
MsgBox ("在追加前请先输入数据")
End If
End Sub
Private Sub Command2_Click() '插入事件过程
intcurr = CInt(InputBox("输入插入位置"))
If intcurr <> 0 And intcurr <= i And Text1 <> "" Then
i = i + 1
ReDim Preserve empwage(i) '重定义数组,保持原数据不变
For j = i To intcurr + 1 Step -1
empwage(j) = empwage(j - 1)
Next j
With empwage(intcurr)
.name = Text1: .title = Text2: .wage = Val(Text3)
End With
Text1 = "": Text2 = "": Text3 = ""
Else
MsgBox ("在插入前请先输入数据")
End If
End Sub
Private Sub Command3_Click() '统计事件过程
If i > 0 Then
For m = 1 To i
sum = sum + empwage(m).wage
Next m
Picture1.Print "工资总额=" & sum
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -