Find Word in Sentence

Discussion in 'AutoCAD' started by Sergio, Jul 8, 2004.

  1. Sergio

    Sergio Guest

    Thanks,

    I am inexperienced in VBA, could you please help me ? How can I do in this
    example?

    Sergio
     
    Sergio, Jul 8, 2004
    #1
  2. Sergio

    Sergio Guest

    Using VBA, as I only obtain the "Wood" type in the "Doors &
    Windows.Wood Doors.Ash" ?

    Sergio
     
    Sergio, Jul 8, 2004
    #2
  3. The InStr function returns a number indicating where one string is found
    within another.
     
    Frank Oquendo, Jul 8, 2004
    #3
  4. There are examples and a breakdown of all the parameters in the VBA help
    file.
     
    Frank Oquendo, Jul 8, 2004
    #4
  5. Sergio

    Dan Cannon Guest

    Dim FirstString As String
    Dim SecondString As String
    Dim WhereInString As Integer
    Dim WholeSentence As Variant
    Dim ReplaceWith As String
    Dim I As Integer

    FirstString = "The big brown fox jumps over the log."
    SecondString = "fox"

    WhereInString = InStr(FirstString, SecondString)
    If WhereInString Then MsgBox SecondString & " occurs " & Str(WhereInString)
    & " characters from the beginning of the sentence."

    ReplaceWith = InputBox("What should I replace 'fox' with?")

    WholeSentence = Split(FirstString, " ")

    FirstString = ""

    For I = 0 To UBound(WholeSentence)
    If WholeSentence(I) = SecondString Then WholeSentence(I) = ReplaceWith
    FirstString = FirstString & " " & WholeSentence(I)
    Next I

    MsgBox Trim$(FirstString)


    HTH.
     
    Dan Cannon, Jul 9, 2004
    #5
  6. Sergio

    Sergio Guest

    Thanks, Dan and Frank

    Sergio
     
    Sergio, Jul 9, 2004
    #6
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.