[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.
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:
String = String.Concat(oldString, NewString, NewString2)
'For instance, instead of
'messout = messout & " - " & messone
'you could do
messout = String.Concat(messout , " - ", messone)
Substring will grab parts from a string
vb Code:
' Starting point , number of chars
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?
Re: Removing a string from a string