一道VB题 求大神帮忙

大神速度 同学在考试啊
2024-11-29 02:03:25
推荐回答(1个)
回答1:

Private Sub Command1_Click()
Dim Comfiles As String
Dim strTEMP As String
Dim strTEMP1 As String
Dim TextLine As String
Dim GodsCount As Long
'选取路径
CommonDialog1.Filter = "所有文件 |*.*"
CommonDialog1.FilterIndex = 1
CommonDialog1.InitDir = App.Path
CommonDialog1.ShowOpen
Comfiles = CommonDialog1.FileName
strTEMP = InputBox("输入第一个数据:")
Open Comfiles For Input As #11
Do While Not EOF(11)
Line Input #11, TextLine
If InStr(TextLine, strTEMP) <>0Then

strTEMP1 = Split(TextLine, ",")(1)
GodsCount = GodsCount + Val(strTEMP1)

End If
Loop
Debug.Print GodsCount
End Sub