请问怎样实现:一按按钮command1,文本框Text3就显示文本框Text1和文本框Text2相同的字符,如:文本框Text1输入aabdgi,文本框Text2输入abbcdefgh,一按command1,文本框Text3就把相同的abdg分出来。高手请教教,谢谢。。

解决方案 »

  1.   

    for循环去比较吧移动进入基础版面
      

  2.   

    写一个循环
    先取TEXT1的第一个字符与TEXT2比较,然后再取下一个,。。笨点好像
      

  3.   

    去好好看看《数据结构》,里面的算法讲得很清楚,好象叫什么KMP算法吧
      

  4.   

    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
      

  5.   

    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
      

  6.   

    “相同的”含义不确定。
    “abcdefg”与“china”两个词相同的地方内容是"c"和“a”吗?
    “abcdefg”与“code”的相同内容是“c”,“d”、"e"、"de"吗?
    ... ...???