多行文本框中的唯一数字VB.Net

时间:2019-02-06 06:15:18

标签: vb.net

此代码不起作用?我没有收到任何错误,但是我没有显示我的值,但是我看不到哪里出错了。 ConsecutiveNumber2.Text>(TabControl2.TabPages5)-如何在多行文本框中执行此操作?

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
    'Throw everything into a list of String initially.
    Dim AllNumbers1 As New List(Of String)
    'Loop through each TextBox, splitting them by commas
    AllNumbers1.AddRange(TxtConsecutiveNumber2.Text.Split({vbCrLf}, StringSplitOptions.RemoveEmptyEntries))
    'Remove non-integer entries.
    AllNumbers1.RemoveAll(Function(x) Integer.TryParse(x, New Integer) = False)
    'Join the distinct list to an array, then back to comma separated format into wherever you want it output.
    TextBox9.Text = String.Join(",", AllNumbers1.Distinct().ToArray())
End Sub

代码2:

'Throw everything into a list of String initially.
Dim AllNumbers1 As New List(Of String)
'Loop through each TextBox, splitting them by commas
For x = 2 To 3
    AllNumbers1.AddRange(CType(TabControl2.TabPages(5).Controls("txtConsecutiveNumber" & x), TextBox).Text.Split(CChar(",")))
Next
'Remove non-integer entries.
AllNumbers1.RemoveAll(Function(x) Integer.TryParse(x, New Integer) = False)
'Join the distinct list to an array, then back to comma separated format into wherever you want it output.
TextBox9.Text = String.Join(",", AllNumbers1.Distinct().ToArray())

0 个答案:

没有答案