vb 的一个问题 十万火鸡

来源:百度知道 编辑:UC知道 时间:2024/06/04 10:23:25
Private Sub Calc_Click()
Dim s As Integer
For i = 1 To 100

If Arr(i) < 50 Then
Text1.Text = Text1.Text & Arr(i) & " "
s = s + Arr(i)
End If
Next i

Print s

End Sub

Private Sub Form_Load()

End Sub

Private Sub Read_Click()
ReadData
End Sub

Private Sub Save_Click()
WriteData "dataout.txt", s
End Sub
这个程序那儿错了 为什么提示 什么BYref参数类型不符 还有那个S好像是私有的 下面的private应该不能调用吧
完整程序是Option Base 1
Dim Arr(100) As Integer

Sub ReadData()
Open App.Path & "\" & "datain1.txt" For Input As #1
For i = 1 To 100
Input #1, Arr(i)
Next i
Close #1
End Sub

Sub WriteData(Filename As String, Num As Integer)
Open App.Path & "\" & Filename For Output As #1
Print #1, Num
Close #1
End Sub

Private Sub Calc_Click(

把Dim s As Integer放到Dim Arr(100) As Integer 的下面。

测试过没有问题,出错时停在哪?
难道是精简的兼容性比较强?
S要做全局变量否则
Private Sub Save_Click()
WriteData "dataout.txt", s
End Sub
这里的S会没有东西