vb自定义函数问题

来源:百度知道 编辑:UC知道 时间:2024/05/21 16:43:50
Dim a(1 To 9, 1 To 9) As Single
Public Function di(a1 As Integer, a2 As Integer, a3 As Integer, a4 As Integer, a5 As Integer, a6 As Integer, a7 As Integer, a8 As Integer)
flag: a = Int(9 * Rnd) + 1
If (a1 - a) * (a2 - a) * (a3 - a) * (a4 - a) * (a5 - a) * (a6 - a) * (a7 - a) * (a8 - a) = 0 Then GoTo flag
di = a
End Function
Private Sub Command1_Click()
a(1, 1) = Int(9 * Rnd) + 1
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
For j = 2 To 9
a(1, j) = Int(9 * Rnd) + 1
Next j
Text11.Text = a(1, 1)
Text12.Text = a(1, 2)
Text13.Text = a(1, 3)
Text14.Text = a(1, 4)
Text15.Text = a(1, 5)
Text16.Text = a(1, 6)
Text17.Text = a(1, 7)
Text18.Text = a(1, 8)
Text19.Text = a(1, 9)
If 10 ^ a(1, 1) + 10 ^ a(1, 2) + 10 ^ a(1, 3) + 10 ^ a(1, 4) + 10 ^ a(1, 5) + 10 ^ a(1, 6) + 10 ^ a(1, 7) + 10 ^ a(1, 8) + 10 ^ a(1, 9) = 1111111110 Then
Timer1.Enabled = False
Timer2.Enab

因为di传入的类型是integer;而你调用di时候有几个参数用了数组a,数组a是single,因此会出错。具体怎么解决你自己试情况而定……例如修改di传入类型或者修改数组类型或者cint()转换一下……