Results 1 to 7 of 7

Thread: remove duplicate from multi line textbox

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2012
    Posts
    137

    remove duplicate from multi line textbox

    i have had inuff searching wasted 30 min and cant find what am looking for so annoyed can anybody help

  2. #2

  3. #3
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,622

    Re: remove duplicate from multi line textbox

    Well, as a mutliline textbox is really one STRING, you can use split or instr to seach in that string, word for word. If you want to remove a 'line', that could prove difficult. Another method (albiet a long one), you could also go word for word in that string, put them each in a listbox, go through the listbox and remove dupes, and then replace your textbox with your new string. But split is probably your best answer to remove duplicate 'words'/strings in the textbox.

  4. #4
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: remove duplicate from multi line textbox

    first of all you need to know which words to find... and we need to know what is it for and maybe what kind of words you will be looking for and why is it your looking for these words

    for example if you remove the words in a chat you could be doing something bad because if someone write

    Hey how are you today? I hope today will be a good day! Do you need some help with your code?

    ...... so in here you have the word you 3 times (yes only 2, but one would also be "your", if you do use instr() )
    ...... and the word day
    ...... and the word a (if looking with split(text, " "))

    anyways see how it is not good... you will need a list (kind of what sam said) and once you have that list you can look for the words

    unless it is for something that is not suppose to have duplicate words like when receiving data make sure you dont get 3 times the username or 3 times the same file etc...

  5. #5
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: remove duplicate from multi line textbox

    @bogaa: You really do need to slow down and think about your questions before you post them. You give us very little information or detail of exactly what the circumstances are, how the 'duplicate' got there in the first place, what exactly you mean by 'duplicate' and what should happen to the remaining text (eg having removed the 'duplicate' should the whole TextBox then be re-formatted?).

    I could read your question literally:
    Code:
    Dim lngPos As Long
    Dim lngStart As Long
    lngStart = 1
    Do
        lngPos = InStr(lngStart, txt.Text, "duplicate")
        If lngPos > 0 Then
            txt.SelStart = lngPos - 1
            txt.SelLength = 9
            txt.SelText = vbNullString
        End If
        lngStart = lngPos + 1
    Loop Until lngStart > Len(txt.Text) Or lngPos = 0
    which does exactly what you've asked - but I doubt if that's what you want. How do you expect us to be able to help if you don't supply enough information ?

    I suspect that there are some members here who take a look at your Posts, come to the conclusion that there's not enough information and just skip them, when, perhaps they could have helped if you'd given more details.

    Remember that you're much closer to your code then we are.
    Last edited by Doogle; Nov 18th, 2012 at 01:22 AM.

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Oct 2012
    Posts
    137

    Re: remove duplicate from multi line textbox

    sorry doogle nxt time il add more info thanks

  7. #7
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: remove duplicate from multi line textbox

    So, would you like to tell us more about the problem you're having with duplicates?

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