Results 1 to 3 of 3

Thread: [RESOLVED] Removing a string from a string

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2007
    Posts
    751

    Resolved [RESOLVED] Removing a string from a string

    Does this look right?

    When a couple of bits are true, I want set another bit and add a string
    to a string.

    But when it's a false condition, I want to subtract the string from the string.
    I didn't see anything that subtracts as easy as the symbol & will add, so I guess you just make the string empty?

    Code:
    dim messone as string = channel1on
    dim messout as string = results>
    
     If lowbit0 = True And c1 = True Then
                doit1 = True
                messout = messout & " - " & messone
            Else
                doit1 = False
                messout = messout.Replace(messone," ")
            End If
    Thanks.

  2. #2
    Addicted Member spyk3's Avatar
    Join Date
    Apr 2009
    Location
    Dothan, AL
    Posts
    218

    Re: Removing a string from a string

    Looks decent close your " symbols tho to get a blank replacment with no space

    You might also want to look at String.Concat & String.Substring

    Concat will add multiple strings together seperated withonly a comma like:

    vb Code:
    1. String = String.Concat(oldString, NewString, NewString2)
    2. 'For instance, instead of
    3. 'messout = messout & " - " & messone
    4. 'you could do
    5. messout = String.Concat(messout , " - ", messone)

    Substring will grab parts from a string

    vb Code:
    1. '                                Starting point , number of chars
    2. String= String.Substring(String.Length - 4, 4)

    i dont know ur overall, but why even make a change if False, it looks to me like there would be nothing to remove to begin with?

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2007
    Posts
    751

    Re: Removing a string from a string

    Thanks Spyke.

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