随机初始化一个数租
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Text = "扫雷 "
bool(0, 0) = "btn_all "
bool(0, 1) = "T_or_F "
Dim i As Integer
For i = 1 To 64
Dim str As String
str = "btn "
bool(i, 0) = str & i
If i = 35 Then
bool(i, 1) = "T "
Else
bool(i, 1) = "F "
End If
Next
Dim y As Integer
btnsure()
End Sub
这里我是人为的
If i = 35 Then
bool(i, 1) = "T "
Else
bool(i, 1) = "F "
End If
把数组里的第二维改变的
那怎么能随机的在数组里的10个第二维数组为T呢
[解决办法]
Public Class Form1
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim bool(65, 2) As String
Dim i As Int32
For i = 0 To 64 ' 先把第二行全部赋为 "F "
bool(i, 1) = "F "
Next
i = 0
While i < 10 ' 随机找出10个赋为 "T "
Dim r As New Random
Dim j As Int32 = r.Next(0, 64)
If bool(j, 1) = "F " Then
bool(j, 1) = "T "
i += 1
End If
End While
End Sub
End Class