Private Sub Command1_Click()
'On Error Resume Next
Dim a As Integer
Dim b As Integer
Dim c As Integer
Dim e As Integer
Dim f As Integer
Dim g As Integer
Dim h As Integer
Dim x(4) As Single
x(1) = Text1.Text
x(2) = Text2.Text
x(3) = Text3.Text
x(4) = Text4.Text
List1.Clear
For e = 1 To 4
For f = 1 To 4
If e <> f Then
For g = 1 To 4
If g <> e And g <> f Then
For h = 1 To 4
If h <> g And h <> f And h <> e Then
For a = 1 To 4
For b = 1 To 4
For c = 1 To 4
If twoNum(twoNum(x(e), x(f), a), twoNum(x(g), x(h), b), c) = 24 Then List1.AddItem twoStr(twoStr(x(e), x(f), a), twoStr(x(g), x(h), b), c)
If twoNum(x(e), twoNum(x(f), twoNum(x(g), x(h), c), b), a) = 24 Then List1.AddItem twoStr(x(e), twoStr(x(f), twoStr(x(g), x(h), c), b), a)
If twoNum(x(e), twoNum(twoNum(x(f), x(g), c), x(h), b), a) = 24 Then List1.AddItem twoStr(x(e), twoStr(twoStr(x(f), x(g), c), x(h), b), a)
If twoNum(twoNum(twoNum(x(e), x(f), a), x(g), b), x(h), c) = 24 Then List1.AddItem twoStr(twoStr(twoStr(x(e), x(f), a), x(g), b), x(h), c)
If twoNum(twoNum(x(e), twoNum(x(f), x(g), a), b), x(h), c) = 24 Then List1.AddItem twoStr(twoStr(x(e), twoStr(x(f), x(g), a), b), x(h), c)
'List1.AddItem twoStr(twoStr(x(e), x(f), a), twoStr(x(g), x(h), b), c) & "=" & twoNum(twoNum(x(e), x(f), a), twoNum(x(g), x(h), b), c)
Next
Next
Next
End If
Next
End If
Next
End If
Next
Next
End SubPrivate Sub Form_Load()
Randomize
Text1.Text = Int(Rnd * 10) + 1
Text2.Text = Int(Rnd * 10) + 1
Text3.Text = Int(Rnd * 10) + 1
Text4.Text = Int(Rnd * 10) + 1
End Sub
Function twoNum(one As Single, two As Single, i As Integer) As Single
On Error Resume Next
Select Case i
Case 1
twoNum = one + two
Case 2
twoNum = one - two
Case 3
twoNum = one * two
Case 4
twoNum = one / two
End Select
End FunctionFunction twoStr(ones As String, twos As String, i As Integer) As String
On Error Resume NextSelect Case i
Case 1
twoStr = "(" & one & "+" & two & ")"
Case 2
twoStr = "(" & one & "-" & two & ")"
Case 3
twoStr = one & "*" & two
Case 4
twoStr = one & "/" & two
End Select
End Function
运行的话,会出现错误:ByRef 参数类型不符
搞了一个晚上还是不知道怎么搞,请问该怎样修改一下代码,谢谢大家了
'On Error Resume Next
Dim a As Integer
Dim b As Integer
Dim c As Integer
Dim e As Integer
Dim f As Integer
Dim g As Integer
Dim h As Integer
Dim x(4) As Single
x(1) = Text1.Text
x(2) = Text2.Text
x(3) = Text3.Text
x(4) = Text4.Text
List1.Clear
For e = 1 To 4
For f = 1 To 4
If e <> f Then
For g = 1 To 4
If g <> e And g <> f Then
For h = 1 To 4
If h <> g And h <> f And h <> e Then
For a = 1 To 4
For b = 1 To 4
For c = 1 To 4
If twoNum(twoNum(x(e), x(f), a), twoNum(x(g), x(h), b), c) = 24 Then List1.AddItem twoStr(twoStr(x(e), x(f), a), twoStr(x(g), x(h), b), c)
If twoNum(x(e), twoNum(x(f), twoNum(x(g), x(h), c), b), a) = 24 Then List1.AddItem twoStr(x(e), twoStr(x(f), twoStr(x(g), x(h), c), b), a)
If twoNum(x(e), twoNum(twoNum(x(f), x(g), c), x(h), b), a) = 24 Then List1.AddItem twoStr(x(e), twoStr(twoStr(x(f), x(g), c), x(h), b), a)
If twoNum(twoNum(twoNum(x(e), x(f), a), x(g), b), x(h), c) = 24 Then List1.AddItem twoStr(twoStr(twoStr(x(e), x(f), a), x(g), b), x(h), c)
If twoNum(twoNum(x(e), twoNum(x(f), x(g), a), b), x(h), c) = 24 Then List1.AddItem twoStr(twoStr(x(e), twoStr(x(f), x(g), a), b), x(h), c)
'List1.AddItem twoStr(twoStr(x(e), x(f), a), twoStr(x(g), x(h), b), c) & "=" & twoNum(twoNum(x(e), x(f), a), twoNum(x(g), x(h), b), c)
Next
Next
Next
End If
Next
End If
Next
End If
Next
Next
End SubPrivate Sub Form_Load()
Randomize
Text1.Text = Int(Rnd * 10) + 1
Text2.Text = Int(Rnd * 10) + 1
Text3.Text = Int(Rnd * 10) + 1
Text4.Text = Int(Rnd * 10) + 1
End Sub
Function twoNum(one As Single, two As Single, i As Integer) As Single
On Error Resume Next
Select Case i
Case 1
twoNum = one + two
Case 2
twoNum = one - two
Case 3
twoNum = one * two
Case 4
twoNum = one / two
End Select
End FunctionFunction twoStr(ones As String, twos As String, i As Integer) As String
On Error Resume NextSelect Case i
Case 1
twoStr = "(" & one & "+" & two & ")"
Case 2
twoStr = "(" & one & "-" & two & ")"
Case 3
twoStr = one & "*" & two
Case 4
twoStr = one & "/" & two
End Select
End Function
运行的话,会出现错误:ByRef 参数类型不符
搞了一个晚上还是不知道怎么搞,请问该怎样修改一下代码,谢谢大家了
解决方案 »
- VB6.0的如何使用外接程序 rational rose把代码转换为模型
- 初来论坛问一下,够多少分增加一个星呀,找了一下没找到具体的规则?
- 两个数据库之间能不能实现多个表之间的交互查询?
- 请问如何用代码实现将Form上的控件置于最顶层?
- 谁用过TrueDBGrid6.0这个第三方控件,我想在复选框后边加个序号,怎么加?checkbox 和序号同属一columns?望高手赐教!
- 如何设置窗口保持最前端,像msgbox一样?
- 有关使用 VB 制作全局 HOOK 的问题
- 正确的写法怎么写,才能不把"标签数组"当成"函数"用?
- 请教各位高手:VB如何控制EXCEL文档的列宽,以及如何更改字体颜色,和有设置边框线。
- 在线等待,有帮助的回答一定给分!!!!!!!!!!!!!!!!!!!!
- VB如何编程更改IE代理服务器
- 突然发现,dim语句竟然可以写在循环语句中,我晕了
Function twoNum(ByVal one As Single, ByVal two As Single, ByVal i As Integer) As SingleFunction twoStr(ByVal ones As String, ByVal twos As String, ByVal i As Integer) As String
就是参数全部由传址改传值.