用vb编程,怎样将两个文本框中的不同的数字找出来,显示在另外一个文本框中?
2个回答
展开全部
以下代码调试通过,注意数字间用空格隔开
Private Sub Command1_Click()
Dim numArr1
Dim numArr2
Dim i As Integer
numArr1 = Split(Text1.Text, " ") ‘如果用逗号隔开就应该是Split(Text1.Text,",")
numArr2 = Split(Text2.Text, " ")
For i = 0 To UBound(numArr1)
If InStr(Text2.Text, numArr1(i)) = 0 Then Text3.Text = Text3.Text & numArr1(i) & " "
Next
For i = 0 To UBound(numArr2)
If InStr(Text1.Text, numArr2(i)) = 0 Then Text3.Text = Text3.Text & numArr2(i) & " "
Next
End Sub
Private Sub Command1_Click()
Dim numArr1
Dim numArr2
Dim i As Integer
numArr1 = Split(Text1.Text, " ") ‘如果用逗号隔开就应该是Split(Text1.Text,",")
numArr2 = Split(Text2.Text, " ")
For i = 0 To UBound(numArr1)
If InStr(Text2.Text, numArr1(i)) = 0 Then Text3.Text = Text3.Text & numArr1(i) & " "
Next
For i = 0 To UBound(numArr2)
If InStr(Text1.Text, numArr2(i)) = 0 Then Text3.Text = Text3.Text & numArr2(i) & " "
Next
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询