其它一切正常,就是每次运行后机选出来的数字都一样,如第一次运行点击选择按钮后出的数字为1234567,第二次运行后还出1234567,有什么办法刷新吗?Private Sub Command1_Click()    Text1.Text = Int(Rnd() * 10)
    Text2.Text = Int(Rnd() * 10)
    Text3.Text = Int(Rnd() * 10)
    Text4.Text = Int(Rnd() * 10)
    Text5.Text = Int(Rnd() * 10)
    Text6.Text = Int(Rnd() * 10)
    Text7.Text = Int(Rnd() * 10)
    
End SubPrivate Sub Command2_Click()
    Text1.Text = ""
    Text2.Text = ""
    Text3.Text = ""
    Text4.Text = ""
    Text5.Text = ""
    Text6.Text = ""
    Text7.Text = ""
End SubPrivate Sub Form_Load()
    Text1.Text = ""
    Text2.Text = ""
    Text3.Text = ""
    Text4.Text = ""
    Text5.Text = ""
    Text6.Text = ""
    Text7.Text = ""
End Sub

解决方案 »

  1.   

    加上这个就好了。
    Randomize Timer         '随机种子数
    一下是我写的一个模块 你可以看看'*************************************************************************
    '**模 块 名:mod_RanDom
    '**说    明:大连天韵 版权所有2005 - 2006(C)
    '**创 建 人:明天(梦天阳)
    '**日    期:2005年05月15日
    '**修 改 人:
    '**日    期:
    '**描    述:
    '**版    本:V1.0
    '*************************************************************************Option Base 1
    '*************************************************************************
    '**函 数 名:RandomInfo
    '**输    入:Germ(Long)            -随机数范围
    '**        :Unit(Long)            -随机数量
    '**        :Ran()(Long)           -存放随机数
    '**        :IsCompositor(Boolean) -是否排序
    '**输    出:随机数
    '**功能描述:
    '**全局变量:
    '**调用模块:
    '**作    者:明天(梦天阳)
    '**日    期:2005年05月15日
    '**修 改 人:
    '**日    期:
    '**版    本:V1.0
    '*************************************************************************
    Public Function RandomInfo(ByVal Germ As Long, Unit As Long, Ran() As Long, Optional IsCompositor As Boolean = False)
    Dim i, j As Long
    Dim Rantemp, IsRan, temp As LongRandomize Timer                             '随机种子数
    ReDim Ran(Unit)For i = 1 To Unitrepeat:
        
        Rantemp = Int(Rnd * Germ)
        IsRan = 0
        
        If Rantemp = 0 Then GoTo repeat
        
        If i = 1 Then
            Ran(1) = Rantemp
        End If
        For j = 1 To i - 1
            
            If Ran(j) <> Rantemp Then
                 IsRan = IsRan + 1
            Else
                GoTo repeat              '发现重复重新生成随机数
            End If
            
            If IsRan = i - 1 Then
                Ran(i) = Rantemp
            End If
           
        Next j
        
    Next i
    If IsCompositor = True Then
        For i = 1 To Unit - 1
            For j = 1 To Unit - 1
                If Ran(j) > Ran(j + 1) Then
                    temp = Ran(j + 1)
                    Ran(j + 1) = Ran(j)
                    Ran(j) = temp
                ElseIf Ran(j) = Ran(j + 1) Then
                    MsgBox "有相等的!", vbInformation, "提示"
                    Exit Function
                End If
            Next j
        Next i
    End If
    DoEvents
    End Function
      

  2.   


    Private Sub Command1_Click()    Randomize    '加这一句!!!    Text1.Text = Int(Rnd() * 10)
        Text2.Text = Int(Rnd() * 10)
        Text3.Text = Int(Rnd() * 10)
        Text4.Text = Int(Rnd() * 10)
        Text5.Text = Int(Rnd() * 10)
        Text6.Text = Int(Rnd() * 10)
        Text7.Text = Int(Rnd() * 10)
        
    End Sub