可以设个中间变量将其进行传递。 比如: if t1<t2 then t3=t1 t1=t2 t2=t3 end if 然后再进行减法运算 a = " " & t1.Text & "-" & t2.Text & "= "
我试了一下,这个代码可以:Dim a As Integer, result As Integer Text2.Text = Int(Rnd * 10 + 1) Text3.Text = Int(Rnd * 10 + 1) If Val(Text2.Text) < Val(Text3.Text) Then a = Text2.Text Text2.Text = Text3.Text Text3.Text = a result = Text2.Text - Text3.Text Text4.Text = result Else: result = Text2.Text - Text3.Text Text4.Text = result
比如:
if t1<t2 then
t3=t1
t1=t2
t2=t3
end if
然后再进行减法运算
a = " " & t1.Text & "-" & t2.Text & "= "
Text2.Text = Int(Rnd * 10 + 1)
Text3.Text = Int(Rnd * 10 + 1)
If Val(Text2.Text) < Val(Text3.Text) Then
a = Text2.Text
Text2.Text = Text3.Text
Text3.Text = a
result = Text2.Text - Text3.Text
Text4.Text = result
Else: result = Text2.Text - Text3.Text
Text4.Text = result
写成这样就没问题了
int(t1.text)<int(t2.text)
a = " " & t1.Text & "-" & t2.Text & "= "
Else cdbl(t1.Text) < cdbl(t2.Text) Then
a = " " & t2.Text & "-" & t1.Text & "= "
End If
a = " " & t1.Text & "-" & t2.Text & "= "
Else
a = " " & t2.Text & "-" & t1.Text & "= "
End If