我有一个richtextbox,我将单词转换为一个数组,然后我的代码将获取长度并输出它......唯一的问题是我不知道如何遍历数组的所有不同值来检查数组的每个单独部分的长度。
(我在 TextChanged 上有这个设置)
Dim len1, len2, len3, len4, len5, len6, len7, len8, len9, len10, len11, len12, len13, len14, len15 As Integer
Dim input As String
Dim words As String()
Dim length As Integer
input = RichTextBox1.Text
words = input.Split(New String() {" "}, StringSplitOptions.RemoveEmptyEntries)
For Each w In words
length = Len(w)
Select Case length
Case 1
len1 = len1 + 1
Case 2
len2 = len2 + 1
Case 3
len3 = len3 + 1
Case 4
len4 = len4 + 1
Case 5
len5 = len5 + 1
Case 6
len6 = len6 + 1
Case 7
len7 = len7 + 1
Case 8
len8 = len8 + 1
Case 9
len9 = len9 + 1
Case 10
len10 = len10 + 1
Case 11
len11 = len11 + 1
Case 12
len12 = len12 + 1
Case 13
len13 = len13 + 1
Case 14
len14 = len14 + 1
Case 15
len15 = len15 + 1
End Select
Next
letcount.onelet.Text = Val(len1)
letcount.twolet.Text = Val(len2)
letcount.threelet.Text = Val(len3)
letcount.fourlet.Text = Val(len4)
letcount.fivelet.Text = Val(len5)
letcount.sixlet.Text = Val(len6)
letcount.sevenlet.Text = Val(len7)
letcount.eightlet.Text = Val(len8)
letcount.ninelet.Text = Val(len9)
letcount.tenlet.Text = Val(len10)
letcount.elevenlet.Text = Val(len11)
letcount.twelevelet.Text = Val(len12)
letcount.thirteenlet.Text = Val(len13)
letcount.fourteenlet.Text = Val(len14)
letcount.fifteenlet.Text = Val(len15)