用户在GUI字段tb_TopicCounts
中添加一个数字(介于3到5之间),根据这个数字,我想将用户添加到文本框tb_topic1, tb_topic2...
中的文本写到List(of String)
中。这就是我尝试过的
Dim topicText As New List(Of String)
For i As Integer = 1 To Convert.ToInt16(tb_TopicsCount.Text)
With topicText
.Add(tb_topic & i & .text)
End With
Next i
.Add(tb_topic & i & .text)
部分无效,我想这是因为它不是字符串,但是我无法提出另一种方法来完成此操作。有人可以帮我吗?
答案 0 :(得分:1)
这就是窍门:
Dim lst As New List(Of String)
For i As Integer = 1 To 2
lst.Add(CType(Me.Controls("TextBox" & i), TextBox).Text)
Next