Results 1 to 6 of 6

Thread: finding

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 1999
    Posts
    204

    Unhappy

    what is a good find code for rich text because im making a program and i need to find some text and i did that and i replaced it and all but now if it's not there i need to make it the text i need to place there

    ex i need to find mike
    found mike
    ex2 nned to find me
    did not find mike want to place it somewhere
    WHat would we do with out Microsoft.
    A lot more.

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    'don't foget to add 2 spaces for each line
    'in a richtextbox because of the cblf factor
    Option Explicit
    Option Compare Text
    
    Private Sub Command2_Click()
        Dim myString As String
        myString = RichTextBox1.Text
        
        If myString Like "*Mike*" Then
            myString = Replace(myString, "Mike", "Replacement")
            MsgBox myString
        Else
    'add Replace at the 24th position of the richtextbox
            RichTextBox1.SelStart = 24
            RichTextBox1.SelText = "Replace"
            MsgBox RichTextBox1.Text
        End If
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 1999
    Posts
    204
    thanks , but i need it at a certen please in teh text box how whould i find the please.

    ex - i neded to place the title

    <html>
    <head>
    the title goes here how whould i do thing
    </head>

    sorry about this im not good with this text stuff

  4. #4
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    Option Explicit
    Option Compare Text
    
    Private Sub Command2_Click()
        If RichTextBox1.Text Like "*the title goes here how whould i do thing *" Then
           RichTextBox1.Text = Replace(RichTextBox1.Text, _
              "the title goes here how whould i do thing", _
                 "<Title>My Title Goes Here</Title>")
        Else
       'assuming there is nothing between the <Head> and </Head> tags put it there
        Dim SearchString, SearchChar, MyPos
        SearchString = RichTextBox1.Text    '  search in.
        SearchChar = "<Head>"   ' Search for "P".
        'if found MyPos will be > 0
    
        MyPos = InStr(1, SearchString, SearchChar, 1)
              
        If MyPos > 0 Then
            RichTextBox1.SelStart = MyPos + 6
            RichTextBox1.SelText = vbCrLf & "<Title>my title goes here</Title>"
         End If
        End If
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jan 1999
    Posts
    204
    why isnt this working i made it into a funcytion please help me

    Public Sub WebWrighter_Find(Find As String, Replace As String, Search_Char As String)

    If frmMain.ActiveForm.txtWebWrighter.Text Like Find Then
    frmMain.ActiveForm.txtWebWrighter.Text = Replace(frmMain.ActiveForm.txtWebWrighter.Text, _
    Find, _
    Replace)
    Else
    'assuming there is nothing between the <Head> and </Head> tags put it there
    Dim SearchString, SearchChar, MyPos
    SearchString = frmMain.ActiveForm.txtWebWrighter.Text ' search in.
    SearchChar = Search_Char ' Search for "P".
    'if found MyPos will be > 0

    MyPos = InStr(1, SearchString, SearchChar, 1)

    If MyPos > 0 Then
    frmMain.ActiveForm.txtWebWrighter.SelStart = MyPos + 6
    frmMain.ActiveForm.txtWebWrighter.SelText = vbCrLf & Replace
    End If
    End If

    End Sub

    pleaaaaaase help me



    [Edited by BoB on 10-02-2000 at 05:43 PM]
    WHat would we do with out Microsoft.
    A lot more.

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jan 1999
    Posts
    204
    i got it thanks
    WHat would we do with out Microsoft.
    A lot more.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width