试图从数组加载文本数(trying to load textbox number from arra

2019-10-29 17:00发布

是有可能加载文本框号码作为一个阵列。 该数组保存了一些它通过每个函数调用我绑这样做增加了1:

    TextBox(num).text = word(curNumber.ToString())

但它没有工作。 我将是提前任何帮助的感谢感激

编辑:什么,我事实上是在试图做的是创建为我做了其他项目密钥生成器\将使这里是代码:

    Public Class Form1
Dim word(20) As String
Dim num(5) As TextBox
Dim alreadyPicked As List(Of Integer) = New List(Of Integer)

Public Sub random()
    num = num + 1 'error here
    Dim curNumber As Integer
    If (alreadyPicked.Count < 21) Then
        Dim rand As Random = New Random
        Do
            curNumber = rand.Next(1, 21)
        Loop While (alreadyPicked.Contains(curNumber))
    End If


    If (curNumber > 0 AndAlso Not alreadyPicked.Contains(curNumber)) Then
        alreadyPicked.Add(curNumber)
        TextBox2.Text = TextBox2.Text + curNumber.ToString() + ", "
        num.text = word(curNumber.ToString()) 'error here
    Else
        MessageBox.Show("Error")
    End If

End Sub



Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    random()
    random()
    random()
    random()
    random()
    random()
    random()
    random()
    random()
    random()
    random()
    random()
    random()
    random()
    random()
    random()
    random()
    random()
    random()
    random()
    alreadyPicked = New List(Of Integer)
    TextBox2.Text += Environment.NewLine
End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    word(0) = "1A"
    word(1) = "2D"
    word(2) = "2D"
    word(3) = "1A"
    word(4) = "3B"
    word(5) = "1E"
    word(6) = "5A"
    word(7) = "6E"
    word(8) = "6D"
    word(9) = "1E"
    word(10) = "7C"
    word(11) = "2A"
    word(12) = "6B"
    word(13) = "2D"
    word(14) = "7D"
    word(15) = "4E"
    word(16) = "9A"
    word(17) = "8B"
    word(18) = "4C"
    word(19) = "7E"
End Sub

Private Sub TextBox(num As Integer())
    Throw New NotImplementedException
End Sub

末级

文章来源: trying to load textbox number from array