经费统计求和.frm
来自「蒋加伏主编VB程序设计第四版PPT及全部课本源码 北京邮电大学出版社 」· FRM 代码 · 共 76 行
FRM
76 行
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 + =
减小字号Ctrl + -
显示快捷键?