每个2文本框的循环
问题描述:
我一直在想如何循环我的文本框有一个整数作为一个值,并将其插入到一个列表视图。我的文本框从Textbox2.Text开始,并以Textbox41.Text结尾。事情是我需要检查每个2文本框(例如textbox2和textbox3)并插入一个列表视图。我不知道如何循环其他文本框。每个2文本框的循环
Try
If TextBox2.Text <> Nothing And TextBox3.Text <> Nothing Then
Pid += 1
At = TextBox2.Text
Bt = TextBox3.Text
Table = ListView1.Items.Add(Pid)
With Table
.SubItems.Add(At)
.SubItems.Add(Bt)
End With
TextBox2.Text = Nothing
TextBox3.Text = Nothing
End If
Catch ex As Exception
MsgBox("Must be numbers!")
End Try
答
如果您的应用程序是Windows窗体,这是你如何能得到的所有整数值...
Dim intList As New List(Of Integer)()
For Each c As Control In Me.Controls
If c.GetType Is GetType(TextBox) Then
Dim txtControl As TextBox = CType(c, TextBox)
If Integer.TryParse(txtControl.Text, 0) Then
intList.Add(Convert.toInt32(txtControl.Text))
End If
End If
Next
请添加更多信息的问题。你试过什么了? –
您的应用程序是Windows窗体还是Web? –
我的应用程序是Windows窗体:) – Yliah