扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
Label1.Text =a(i,j) " "
创新互联长期为上千家客户提供的网站建设服务,团队从业经验10年,关注不同地域、不同群体,并针对不同对象提供差异化的产品和服务;打造开放共赢平台,与合作伙伴共同营造健康的互联网生态环境。为平顶山企业提供专业的成都网站制作、网站设计、外贸网站建设,平顶山网站改版等技术服务。拥有10年丰富建站经验和众多成功案例,为您定制开发。
相当于
Label1.Text = Label1.Text a(i,j) " "
1。不能,语法问题。
2。“ ”中包含的是空格,这句话相当于将数组a中的所有数据罗列出来,空格是分隔符,没有它数据就连在一起了,你没法区分了!
想要生成多少个都行。
Randomize()随机打乱
dim a1 as integer=cint(rnd()*32))+1
dim a2 as integer=cint(rnd()*32))+1
dim a3 as integer=cint(rnd()*32))+1
dim a4 as integer=cint(rnd()*32))+1
dim a5 as integer=cint(rnd()*32))+1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Randomize() '产生随机数种子 以防止每次生成结果都一样
Dim a(100) As Integer '声明数组存放数据 用来保存随机数结果
Dim max As Integer, min As Integer '声明两个变量存最大值和最小值
min = 1000 : max = 0 '设置初值
For i = 0 To 99 '循环100次
a(i) = Int(Rnd() * 1000 + 1) '用rnd生成一个随机数 由于rnd范围为0-1之间的小数.所以*1000设置他的范围为0到999之间 加1变成1到1000之间
If a(i) = max Then max = a(i) '如果当前数值大于最大值的变量就保存
If a(i) = min Then min = a(i) '如果当前数值小于最小值的变量就保存
Next
MsgBox("最大值为" max)
MsgBox("最小值为" min)
End Sub
下面是你需要的,经过三次随机,可以看一下,直接调用函数返回一个字符就是你要的,看不懂再追问哈
Structure jiqi
Dim num As Integer
Dim num2 As Integer
End Structure
Public Function chansheng() As String
Dim str As String = ""
Dim n As Integer = 0
Dim p68 As Integer
Randomize()
p68 = Int(Rnd() * 2) + 1
Dim a(10), b(8) As Integer
For i = 1 To 6
b(i) = i - 1
Next
b(7) = 7
b(8) = 9
For i = 1 To 6
Randomize()
a(i) = b(Int(Rnd() * 8) + 1)
Next
If p68 = 1 Then
For i = 7 To 10
a(i) = 6
Next
ElseIf p68 = 2 Then
For i = 7 To 10
a(i) = 8
Next
End If
Dim c(10) As Integer
Dim temp As jiqi
Dim pi(10) As jiqi
For i = 1 To 10
pi(i).num = a(i)
pi(i).num2 = Int(Rnd() * 1000) + 10
Next
For i = 1 To 10
For j = 1 To 10 - i
If pi(j).num2 pi(j + 1).num2 Then
temp = pi(j + 1)
pi(j + 1) = pi(j)
pi(j) = temp
End If
Next j
Next i
For i = 1 To 10
str = str pi(i).num
Next
Return str
End Function
Private Sub Command1_Click()
Dim num(6) As Integer
Dim i As Integer, j As Integer
Dim tmp As Integer
Randomize '防止每次生出随机数一样
For i = 0 To 5
num(i) = Int(Rnd * 53) + 1
Next
PrintNum "新生成的6个随机数为:", num()
For i = 0 To 5
For j = 0 To 5
If num(j) num(j + 1) Then
tmp = num(j)
num(j) = num(j + 1)
num(j + 1) = tmp
End If
Next
Next
PrintNum "排序后的6个随机数为:", num()
End Sub
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流