Results 1 to 5 of 5

Thread: [RESOLVED] Delete parts of a string.

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2008
    Posts
    37

    Resolved [RESOLVED] Delete parts of a string.

    Translated:


    Hello first off, I've only been begun with VB 6.0 and have a problem -- I hope that I can get help here.

    My problem is that I want to delete a part from a string and then put the remaining part into a textbox.

    ws.GetData sData

    My socket writes the data into sData like this, but I needs to be checked to see if it begins with "abc123 -" and then delete the abc123 part and write the rest into a text box. I have already searched everywhere on the net but nothing with the correct usage... I don't know how to split things out and even a tutorial was of no use (LOL!). I would be grateful for any help.


    Greetz Kaikou
    (thanks to Comintern for translating)


    Original:
    Hallo erstmals, ich habe vor ein paar tagen angefangen mit VB 6.0 und habe nun ein problem ^^ ich hoffe das mir hier geholfen wird.

    Mein problem ist, das ich teile von einem string löschen will und den nicht gelöschten teil in einer textbox reinschreiben lassen.

    ws.GetData sData

    Mein socket bekommt also daten die in sData reingeschrieben werden. die sData sind unbekannt allerdings sollte es überprüfen ob der string mit "abc123-" anfängt und den teil abc123- löscht und den rest in eine textbox schreibt. ich hab schon überall im netzt gesucht konnte aber nichts so richtig gebrauchen... kenn mich mit dem Split zeugs nicht so aus und selbst ein tutorial hat da nix gebracht (LOL!). Wäre dankbar für jede hilfe.


    Gruss Kaikou ^^
    Last edited by Kaikou; Jan 18th, 2008 at 06:54 AM. Reason: German -> English

  2. #2
    Fanatic Member Comintern's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln, NE
    Posts
    826

    Re: teile von einem string löschen

    Willkommen ins VB Forums. Erstmals, Englisch ist die Sprache des Forums. Ich habe ein bissen deutsch, aber nur ein bissen. Versuchen Sie diesen Code:
    Code:
        If Left$(sData, 8) = "abc123 -" Then
            If Len(sData) > 8 Then
                TextBox1.Text = Right$(sData, Len(sData) - 8)
            Else
                TextBox1.Text = vbNullString
            End If
        End If
    oder:
    Code:
    sData = Replace$(sData, "abc123 -", vbNullString)
    Translation:

    Quote Originally Posted by Kaikou (roughly)
    Hello first off, I've only been begun with VB 6.0 and have a problem -- I hope that I can get help here.

    My problem is that I want to delete a part from a string and then put the remaining part into a textbox.

    ws.GetData sData

    My socket writes the data into sData like this, but I needs to be checked to see if it begins with "abc123 -" and then delete the abc123 part and write the rest into a text box. I have already searched everywhere on the net but nothing with the correct usage... I don't know how to split things out and even a tutorial was of no use (LOL!). I would be grateful for any help.
    Quote Originally Posted by Comintern
    Welcome to VB Forums. First of all, English is the language of this forum. I know a little German, but only a little bit. Try this code:
    Code:
        If Left$(sData, 8) = "abc123 -" Then
            If Len(sData) > 8 Then
                TextBox1.Text = Right$(sData, Len(sData) - 8)
            Else
                TextBox1.Text = vbNullString
            End If
        End If
    or:
    Code:
    sData = Replace$(sData, "abc123 -", vbNullString)
    Last edited by Comintern; Jan 17th, 2008 at 09:23 PM. Reason: Add translation :)

  3. #3
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,427

    Re: teile von einem string löschen

    As I think Comintern said this is an English-language forum so please only post your questions and answers in English. We use English because VB Forums has a world-wide audience and English is the language that is likely to be understood by the most people.

  4. #4

    Thread Starter
    Member
    Join Date
    Jan 2008
    Posts
    37

    Re: teile von einem string löschen

    Thanks, this code works GREAT!!

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Delete parts of a string.

    Welcome to the forums.

    If you consider this resolved, you could help us out by pulling down the Thread Tools menu and clicking the Mark Thread Resolved menu item. That will let everyone know that you have your answer.

    Thank you.

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