用Instr可以实现查找字符串 也可以用它来实现你的功能的

解决方案 »

  1.   

    查找字符串可以用函数Instr()函数,如果找到了返回的是找到的位置,如果找不到返回0。
    替换可以用Replace函数。
      

  2.   

    songyangk(小草) 说的对。
    dim a as string 
    dim i as integer
    dim searchchar as string 
    a="123456"
    searchchar="34"
    i=instr(1,a,searchchar, vbTextCompare)
    replace a,sezrchchar,"43" '''把34替换为43
      

  3.   

    其实很简单,用Replace函数就可以了。
    dim a as string
    a=Replace("I love you","you","VB")
      

  4.   

    呵呵,还得考虑一下向上和向下呢!
    我这有段源码,是我很早以前做的一个编辑器的查找模块,
    至于替换,查找都可以了,替换也就不成问题了,记得给分喔,呵呵~~:'option1为向上,option2为向下查找
    Public Sub FindText(ByVal start_at As Integer)
    Dim target As String
    If myfind.Option1 Then      
        pos = bwl.rtb.SelStart
        bwl.rtb.SelStart = 0
        bwl.rtb.SelLength = pos
        ok = StrReverse(bwl.rtb.SelText)
        bwl.rtb.SelStart = pos
    End If
    If myfind.Option2 Then
        If mynext = 1 And ss = myfind.Text1.Text Then
        pos = bwl.rtb.SelStart + lens
        mynext = 0
        Else
        pos = bwl.rtb.SelStart
        End If
        bwl.rtb.SelStart = pos
        bwl.rtb.SelLength = Len(bwl.rtb.Text) - pos
        ok = bwl.rtb.SelText
        bwl.rtb.SelStart = pos
    End If
        target = myfind.Text1.Text
        If Option1 Then target = StrReverse(target)
        mypos = InStr(start_at, ok, target)
        If mypos > 0 Then
        If Option1 Then
          Targetpos = pos - mypos + 1
          bwl.rtb.SelStart = Targetpos - Len(target)
          bwl.rtb.SelLength = Len(target)
          bwl.rtb.SetFocus
          lens = Len(target)
        End If
        If Option2 Then
          ss = target
          Targetpos = pos + mypos
          mynext = 1
          bwl.rtb.SelStart = Targetpos - 1
          bwl.rtb.SelLength = Len(target)
          bwl.rtb.SetFocus
          lens = Len(target)
        End If
        Else
            MsgBox "没找到!",,"飞龙备忘录"
        End If   
    End Sub
      

  5.   

    textbox就可以了!
    发个form给你!email?
      

  6.   

    little_hero(天生我才必有用!) :
    [email protected]谢谢了!!!
      

  7.   

    cqq_chen(我是谁):
    呵呵,咱是个初学者,以后还会有很多问题请教大家,到时候你可要帮忙哦(一定给分)~~
      

  8.   

    to little_hero(天生我才必有用!)
    没有收到邮件
    ????