vb产生-10 ~ 10 之间的随机整数数
2个回答
展开全部
Private Sub Command1_Click()
Dim i As Integer, k As Integer
Dim strText As String
Dim a(9) As Integer
For i = 0 To 9
Do While Repeat(a(), k, i) '如果重复的话继续获取
k = Int(Rnd * 50 + 1) '获取1~50的整数
Loop
a(i) = k
Next
For i = 0 To 9
strText = strText & " " & a(i)
Next
Label1.AutoSize = True
Label1.Caption = strText
End Sub
Private Function Repeat(a() As Integer, Num As Integer, Index As Integer) As Boolean
'参数:a()表示要判断的数组,Num表示被重复的数字,index表示判断到几号就不看了
Dim j As Integer
For j = LBound(a) To Index '如果有重复则返回True
If Num = a(j) Then Repeat = True: Exit Function
Next
Repeat = False
End Function
Dim i As Integer, k As Integer
Dim strText As String
Dim a(9) As Integer
For i = 0 To 9
Do While Repeat(a(), k, i) '如果重复的话继续获取
k = Int(Rnd * 50 + 1) '获取1~50的整数
Loop
a(i) = k
Next
For i = 0 To 9
strText = strText & " " & a(i)
Next
Label1.AutoSize = True
Label1.Caption = strText
End Sub
Private Function Repeat(a() As Integer, Num As Integer, Index As Integer) As Boolean
'参数:a()表示要判断的数组,Num表示被重复的数字,index表示判断到几号就不看了
Dim j As Integer
For j = LBound(a) To Index '如果有重复则返回True
If Num = a(j) Then Repeat = True: Exit Function
Next
Repeat = False
End Function
大雅新科技有限公司
2024-11-19 广告
2024-11-19 广告
这方面更多更全面的信息其实可以找下大雅新。深圳市大雅新科技有限公司从事KVM延长器,DVI延长器,USB延长器,键盘鼠标延长器,双绞线视频传输器,VGA视频双绞线传输器,VGA延长器,VGA视频延长器,DVI KVM 切换器等,优质供应商,...
点击进入详情页
本回答由大雅新科技有限公司提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询