vb文本框有很多数据数组如1 2 3,1 3 8,2 5 6怎么把含有两个相同数的数组比较出来显示到
vb文本框有很多数据数组如123,138,256怎么把含有两个相同数的数组比较出来显示到另一个文本框。得到结果为123,138两组数据。数与数有空格如123...
vb文本框有很多数据数组如1 2 3,1 3 8,2 5 6怎么把含有两个相同数的数组比较出来显示到另一个文本框。得到结果为1 2 3,1 3 8两组数据。数与数有空格如1 2 3
展开
1个回答
展开全部
Private Sub Command1_Click()
Dim a() As String
Dim n As Integer
Dim b(3) As Integer
Dim c() As Boolean
Dim d() As String
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim l As Integer
Dim s As String
Dim num1 As Integer
Dim str1() As String
str1() = Split(Text1.Text, ",")
n = UBound(str1())
ReDim a(n, 2)
ReDim c(n)
For i = 0 To n
d() = Split(str1(i), " ")
For j = 0 To UBound(d())
a(i, j) = d(j)
Next
Next
For i = 0 To n
For j = 0 To n
c(n) = False
num1 = 0
Next
c(i) = True
num1 = 1
For j = i + 1 To n
Dim m As Integer
For k = 0 To 2
For l = 0 To 2
If a(i, k) = a(j, l) Then
If m = 0 Then
m = 1
Else
m = 2
c(j) = True
num1 = num1 + 1
Exit For
End If
End If
Next
If m = 2 Then Exit For
Next
Next
If num1 > 1 Then Exit For
Next
For i = 0 To n
If c(i) = True Then
For j = 0 To 2
Text2.Text = Text2.Text & a(i, j) & Space(1)
Next
Text2.Text = Text2.Text & ","
End If
Next
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Form_Load()
Text1.Text = "1 2 3,1 3 8,2 5 6"
Text2.Text = ""
Command1.Caption = "开始"
Command2.Caption = "退出"
End Sub
Dim a() As String
Dim n As Integer
Dim b(3) As Integer
Dim c() As Boolean
Dim d() As String
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim l As Integer
Dim s As String
Dim num1 As Integer
Dim str1() As String
str1() = Split(Text1.Text, ",")
n = UBound(str1())
ReDim a(n, 2)
ReDim c(n)
For i = 0 To n
d() = Split(str1(i), " ")
For j = 0 To UBound(d())
a(i, j) = d(j)
Next
Next
For i = 0 To n
For j = 0 To n
c(n) = False
num1 = 0
Next
c(i) = True
num1 = 1
For j = i + 1 To n
Dim m As Integer
For k = 0 To 2
For l = 0 To 2
If a(i, k) = a(j, l) Then
If m = 0 Then
m = 1
Else
m = 2
c(j) = True
num1 = num1 + 1
Exit For
End If
End If
Next
If m = 2 Then Exit For
Next
Next
If num1 > 1 Then Exit For
Next
For i = 0 To n
If c(i) = True Then
For j = 0 To 2
Text2.Text = Text2.Text & a(i, j) & Space(1)
Next
Text2.Text = Text2.Text & ","
End If
Next
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Form_Load()
Text1.Text = "1 2 3,1 3 8,2 5 6"
Text2.Text = ""
Command1.Caption = "开始"
Command2.Caption = "退出"
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询