所以我有一个make to assignment,它基本上希望用户在文本字段中输入随机字母,或者按下随机字母生成器按钮,然后在按下按钮后,会出现这些字母可以生成的单词里面的列表框。我有10个列表框。根据单词的长度,它将显示在相应的列表框中。这是我制作的代码。我的代码创建了排列,并将它们显示在列表框中。这不是最好的方法,因为它可能需要数小时才能找到11个长度字符串的排列。但我现在的问题是,如何使我的代码检查包含200000个英语单词的数组,对于合法的单词并使它们出现在列表框中?
Dim t As Date = Date.Now
Dim chars() As Char = TextBox1.Text.ToCharArray
If TextBox1.Text.Length > 1 Then
For Each c0 As Char In chars
For Each c1 As Char In chars
RankBox2.Items.Add(c0 & c1 & Environment.NewLine)
Next
Next
End If
If TextBox1.Text.Length > 2 Then
For Each c0 As Char In chars
For Each c1 As Char In chars
For Each c2 As Char In chars
RankBox3.Items.Add(c0 & c1 & c2 & Environment.NewLine)
Next
Next
Next
End If
If TextBox1.Text.Length > 3 Then
For Each c0 As Char In chars
For Each c1 As Char In chars
For Each c2 As Char In chars
For Each c3 As Char In chars
RankBox4.Items.Add(c0 & c1 & c2 & c3 & Environment.NewLine)
Next
Next
Next
Next
End If
If TextBox1.Text.Length > 4 Then
For Each c0 As Char In chars
For Each c1 As Char In chars
For Each c2 As Char In chars
For Each c3 As Char In chars
For Each c4 As Char In chars
RankBox5.Items.Add(c0 & c1 & c2 & c3 & c4 & Environment.NewLine)
Next
Next
Next
Next
Next
End If
If TextBox1.Text.Length > 5 Then
For Each c0 As Char In chars
For Each c1 As Char In chars
For Each c2 As Char In chars
For Each c3 As Char In chars
For Each c4 As Char In chars
For Each c5 As Char In chars
RankBox6.Items.Add(c0 & c1 & c2 & c3 & c4 & c5 & Environment.NewLine)
Next
Next
Next
Next
Next
Next
End If
If TextBox1.Text.Length > 6 Then
For Each c0 As Char In chars
For Each c1 As Char In chars
For Each c2 As Char In chars
For Each c3 As Char In chars
For Each c4 As Char In chars
For Each c5 As Char In chars
For Each c6 As Char In chars
RankBox7.Items.Add(c0 & c1 & c2 & c3 & c4 & c5 & c6 & Environment.NewLine)
Next
Next
Next
Next
Next
Next
Next
End If
If TextBox1.Text.Length > 7 Then
For Each c0 As Char In chars
For Each c1 As Char In chars
For Each c2 As Char In chars
For Each c3 As Char In chars
For Each c4 As Char In chars
For Each c5 As Char In chars
For Each c6 As Char In chars
For Each c7 As Char In chars
RankBox8.Items.Add(c0 & c1 & c2 & c3 & c4 & c5 & c6 & c7 & Environment.NewLine)
Next
Next
Next
Next
Next
Next
Next
Next
End If
If TextBox1.Text.Length > 8 Then
For Each c0 As Char In chars
For Each c1 As Char In chars
For Each c2 As Char In chars
For Each c3 As Char In chars
For Each c4 As Char In chars
For Each c5 As Char In chars
For Each c6 As Char In chars
For Each c7 As Char In chars
For Each c8 As Char In chars
RankBox9.Items.Add(c0 & c1 & c2 & c3 & c4 & c5 & c6 & c7 & c8 & Environment.NewLine)
Next
Next
Next
Next
Next
Next
Next
Next
Next
End If
If TextBox1.Text.Length > 9 Then
For Each c0 As Char In chars
For Each c1 As Char In chars
For Each c2 As Char In chars
For Each c3 As Char In chars
For Each c4 As Char In chars
For Each c5 As Char In chars
For Each c6 As Char In chars
For Each c7 As Char In chars
For Each c8 As Char In chars
For Each c9 As Char In chars
RankBox10.Items.Add(c0 & c1 & c2 & c3 & c4 & c5 & c6 & c7 & c8 & c9 & Environment.NewLine)
Next
Next
Next
Next
Next
Next
Next
Next
Next
Next
End If
If TextBox1.Text.Length > 10 Then
For Each c0 As Char In chars
For Each c1 As Char In chars
For Each c2 As Char In chars
For Each c3 As Char In chars
For Each c4 As Char In chars
For Each c5 As Char In chars
For Each c6 As Char In chars
For Each c7 As Char In chars
For Each c8 As Char In chars
For Each c9 As Char In chars
For Each c10 As Char In chars
RankBox11.Items.Add(c0 & c1 & c2 & c3 & c4 & c5 & c6 & c7 & c8 & c9 & c10 & Environment.NewLine)
Next
Next
Next
Next
Next
Next
Next
Next
Next
Next
Next
End If
MsgBox(Date.Now.Subtract(t).TotalSeconds & " seconds")