📄 经费统计求和.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "例[10-8]读文件并统计求和"
ClientHeight = 2505
ClientLeft = 60
ClientTop = 345
ClientWidth = 5175
LinkTopic = "Form1"
ScaleHeight = 2505
ScaleWidth = 5175
StartUpPosition = 3 '窗口缺省
Begin VB.TextBox Text1
Height = 615
Left = 3000
TabIndex = 4
Top = 600
Width = 1935
End
Begin VB.ListBox List1
Height = 1680
ItemData = "三角函数计算.frx":0000
Left = 240
List = "三角函数计算.frx":0002
TabIndex = 2
Top = 600
Width = 2175
End
Begin VB.CommandButton Command1
Caption = "运行"
Height = 615
Left = 3000
TabIndex = 0
Top = 1680
Width = 1935
End
Begin VB.Label Label2
Caption = "经费总和为:"
Height = 375
Left = 3000
TabIndex = 3
Top = 240
Width = 1815
End
Begin VB.Label Label1
Caption = "从文件读数据,显示并相加"
Height = 375
Left = 240
TabIndex = 1
Top = 240
Width = 2415
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Dim sum As Long
Open "d:\outlayi.txt" For Input As #1
'从文件读出每次报销经费,显示并相加
sum = 0
Do While Not EOF(1)
Input #1, n
List1.AddItem n
sum = sum + n
Loop
Close #1
Text1.Text = Str(sum)
'把计算结果(总和)写入文件d:\outlay0.txt
Open "d:\outlay0.txt" For Output As #1
Print #1, "经费总和为: "; sum
Close #1
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -