i wanted to know if there is a way to add or remove text to a label that already have text e.g i have a label that says "Hi," and when i press a button it add "My name is rick" next to "Hi," so that if i have a list of checkbox. Every time i check a box it add the name of that check box next to the previous one e.g. I have 5 check box named - door, screen, laptop, dog and cat - if i press cat the text is going to be "Cat," and then if i press laptop its going to add "Laptop," next to "Cat," so the text would be "Cat, Laptop" but if i uncheck cat it would only be "Laptop," i hope you understand what i mean and thanks to anyone that take the time to help me out.
Asked
Active
Viewed 7,437 times
0
-
Please read http://stackoverflow.com/help/how-to-ask – Alexandre Cartapanis Jun 05 '16 at 14:57
-
How did you set the text in the first place? That might be a good place to start looking. – Andrew Mortimer Jun 05 '16 at 15:02
-
if you so us what you have tried, we will be more than happy to help you out, what we DON'T like to see is no effect made. – user1234433222 Jun 05 '16 at 16:50
1 Answers
-1
To do this all you got to do is make a dim as string and add text on this string using +=(or &=) here is an e.g
Dim textTest As String
if checkbox1.checked = true then
textTest +=(or &=) ("Cat, ")
end if
if checkbox2.checked = true then
textTest +=(or &=) ("Laptop, ")
end if
hope this helped you.

Darkghost620
- 1
- 1
- 5
-
**A)** The parentheses are superfluous. **B)** For the sake of the compiler (and the future), **never** use `+` when concatenating strings. Always use the ampersand `&`. – Visual Vincent Jun 06 '16 at 01:01
-
Thanks for the help but it does not change anything if I put ("") or if I don't put ("") and it does not change anything if I put + or & it just depend on the way i like to code if I like to put ("") in my set string because i am used to it then I do it if you do not code like this then you see that everyone have differences – Darkghost620 Jun 06 '16 at 11:57
-
I know everyone have differences, but it's not a usual thing to put parentheses around the text, which makes them superfluous. -- However using `+=` or `&=` might actually matter. See this: [**The difference between + and & for joining strings in VB.NET**](http://stackoverflow.com/a/734631/3740093). – Visual Vincent Jun 06 '16 at 20:10
-
I've commented on/answered plenty of questions where the user have had the `Conversion from string "" to type 'Double' is not valid` error, which is caused by incorrect use of the `+` operator. – Visual Vincent Jun 06 '16 at 20:13