在交集列表中放置一个条件(计数数字长度)



我只想输出由至少 2 位数字或仅 2 位数字组成的数字。 如果交叉点中有单个数字(单个数字(,则不会将其添加到交叉点。那么我该怎么做呢?因为我没有成功或不太了解这样做的交叉点的功能。

TextBox1.Text = LineTrim(TextBox1.Text)
Dim intersectionList As New List(Of String)()
Dim linesx() As String = TextBox1.Lines
For x As Integer = 1 To linesx.Length - 2
Dim firstBoxList = TextBox1.Lines(x).Split(",")
Dim secondBoxList = TextBox1.Lines(x + 1).Split(",")
If intersectionList.Max.Length = (2) Then
intersectionList.Add(String.Join(",", secondBoxList.Intersect(firstBoxList)))
End If
Next

因此,如果我们在十字路口:

2 4
1
3 4 7
2

在交叉点将仅添加:

2 4 
3 4 7

如果交集列表.最大长度 = (2( 则

Dim strA$(), strT$
strA = Split(TextBox1.Text, vbNewLine)
For i% = 0 to strA.GetUpperBound(0)
If Not Trim(strA(i)).Length.Equals(1) Then
strT += strA(i) & vbNewLine
End If
next
TextBox1.Text = ""
TextBox1.Text = strT

最新更新