Private Sub Command1_Click() Dim i As Long, tmpstr As String, outstr As String For i = 1 To Len(T1.Text) tmpstr = Mid$(T1.Text, i, 1) If InStr(1, T2.Text, tmpstr) Then outstr = outstr & tmpstr Next i MsgBox outstr End Sub
VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 3090 ClientLeft = 60 ClientTop = 450 ClientWidth = 4680 LinkTopic = "Form1" ScaleHeight = 3090 ScaleWidth = 4680 StartUpPosition = 3 '窗口缺省 Begin VB.CommandButton Command1 Caption = "Command1" Height = 495 Left = 1560 TabIndex = 2 Top = 2040 Width = 1695 End Begin VB.TextBox T2 Height = 495 Left = 720 TabIndex = 1 Text = "24" Top = 960 Width = 3495 End Begin VB.TextBox T1 Height = 375 Left = 720 TabIndex = 0 Text = "123456" Top = 480 Width = 3495 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub Command1_Click() Dim i As Long, tmpstr As String, outstr As String For i = 1 To Len(T1.Text) tmpstr = Mid$(T1.Text, i, 1) If InStr(1, T2.Text, tmpstr) Then outstr = outstr & tmpstr Next i MsgBox outstr End Sub
先取TEXT1的第一个字符与TEXT2比较,然后再取下一个,。。笨点好像
Dim i As Long, tmpstr As String, outstr As String
For i = 1 To Len(T1.Text)
tmpstr = Mid$(T1.Text, i, 1)
If InStr(1, T2.Text, tmpstr) Then outstr = outstr & tmpstr
Next i
MsgBox outstr
End Sub
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3090
ClientLeft = 60
ClientTop = 450
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3090
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 495
Left = 1560
TabIndex = 2
Top = 2040
Width = 1695
End
Begin VB.TextBox T2
Height = 495
Left = 720
TabIndex = 1
Text = "24"
Top = 960
Width = 3495
End
Begin VB.TextBox T1
Height = 375
Left = 720
TabIndex = 0
Text = "123456"
Top = 480
Width = 3495
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Dim i As Long, tmpstr As String, outstr As String
For i = 1 To Len(T1.Text)
tmpstr = Mid$(T1.Text, i, 1)
If InStr(1, T2.Text, tmpstr) Then outstr = outstr & tmpstr
Next i
MsgBox outstr
End Sub
“abcdefg”与“china”两个词相同的地方内容是"c"和“a”吗?
“abcdefg”与“code”的相同内容是“c”,“d”、"e"、"de"吗?
... ...???