Int(11 * Rnd) 产生0-10

解决方案 »

  1.   

    可以设个中间变量将其进行传递。
    比如:
    if t1<t2 then
      t3=t1
      t1=t2
      t2=t3
    end if
    然后再进行减法运算
    a = "              " & t1.Text & "-" & t2.Text & "=              "
      

  2.   

    我试了一下,这个代码可以: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
      

  3.   

    t1.text<t2.text比较时是字符串比较,所以2,3,...>10
    写成这样就没问题了
    int(t1.text)<int(t2.text)
      

  4.   

    If cdbl(t1.Text) >= cdbl(t2.Text) Then
        a = "              " & t1.Text & "-" & t2.Text & "=              "
        Else cdbl(t1.Text) < cdbl(t2.Text) Then
        a = "              " & t2.Text & "-" & t1.Text & "=              "
        End If
      

  5.   

    If val(t1.Text) > val(t2.Text) Then
        a = "              " & t1.Text & "-" & t2.Text & "=              "
        Else
        a = "              " & t2.Text & "-" & t1.Text & "=              "
        End If