Results 1 to 5 of 5

Thread: What am I doing wrong? [Resolved]

  1. #1

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    What am I doing wrong? [Resolved]

    Just a simple find and replace... and I just can't get it to work! Ugh I know I'm doing something wrong....
    VB Code:
    1. Private Sub mnuChildFIndandReplace_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuChildFIndandReplace.Click
    2.         'Show The Find And Replace Dialog
    3.         Dim frmReplace As New frmReplace
    4.         Me.AddOwnedForm(frmReplace)
    5.         frmReplace.ShowDialog()
    6.         CurrentToBe = frmReplace.txtReplaceThis.Text
    7.         CurrentReplace = frmReplace.txtReplaceWith.Text
    8.         Dim CharacterNumber As Integer = frmReplace.txtReplaceThis.Text.Length()
    9.         If frmReplace.chkCase.Checked = False Then
    10.             ReplaceWordLocation = txtBoxChild.Find(CurrentToBe, RichTextBoxFinds.None)
    11.             txtBoxChild.Text.Remove(ReplaceWordLocation, CharacterNumber)
    12.             txtBoxChild.Text.Insert(ReplaceWordLocation, CurrentReplace)
    13.         ElseIf frmReplace.chkCase.Checked = True Then
    14.             ReplaceWordLocation = txtBoxChild.Find(CurrentToBe, RichTextBoxFinds.MatchCase)
    15.             txtBoxChild.Text.Remove(ReplaceWordLocation, CharacterNumber)
    16.             txtBoxChild.Text.Insert(ReplaceWordLocation, CurrentReplace)
    17.         End If
    18.     End Sub
    Last edited by Kasracer; Jul 26th, 2003 at 12:40 PM.

  2. #2
    Addicted Member Sheppe's Avatar
    Join Date
    Sep 2002
    Location
    Kelowna, BC
    Posts
    245
    Is there a reason you're not using the built in Replace function?
    [vbcode]
    On Error Goto Hell
    [/vbcode]
    Sheppe Pharis, MCSD
    Check out http://www.vb-faq.com
    Click here for access to the free Code-Express source code and component sharing network for VB6
    Want a better way to skin your .NET applications? Click here!

  3. #3

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    Originally posted by Sheppe
    Is there a reason you're not using the built in Replace function?
    I tried it and it wouldn't work.....

  4. #4
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    instead of using txtBoxChild.Text.Replace( blabla , blabla )
    try this :
    VB Code:
    1. txtBoxChild.Text = Replace( txtBoxChild.Text , "exsisting text " , " New Text " )
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  5. #5

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    Originally posted by dynamic_sysop
    instead of using txtBoxChild.Text.Replace( blabla , blabla )
    try this :
    VB Code:
    1. txtBoxChild.Text = Replace( txtBoxChild.Text , "exsisting text " , " New Text " )
    Thanks that works!

    I tried the replace function with the text box control and several other things and it just wouldn't work! bah.

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