请教各位VB高手,我在学习VB过程中又遇到难题,给我指导一下,最好能给我详细的代码,谢谢。

2024-12-20 20:52:55
推荐回答(2个)
回答1:

Private Sub Command1_Click()
Dim s1 As String, s2 As String, s3 As String
Dim r1 As String, r2 As String
Dim i As Long, a As String
s1 = Text1.Text
s2 = Text2.Text
s3 = Text3.Text
For i = 1 To Len(s1)
a = Mid(s1, i, 1)
If InStr(1, s2, a) Then
r1 = r1 & a
End If
Next
r2 = s1
For i = 1 To Len(s3)
a = Mid(s3, i, 1)
r2 = Replace(r2, a, "")
Next
Text4 = r1
Text5 = r2
End Sub

回答2:

只能输入单数,那你怎么输入 两位以上的数呀
至于交集 和 排除 可以分别用两层循环嵌套 实现,将相同 或者 排除的 数字组成字符串显示到 text4和 text5