Zack Ball Zack Ball -5 years ago 214 Question

Adding characters to the beginning and end of a string?

Evening everyone, first timer here, I have tried to research this as best as I could but to no avail. Probably because I'm still rough on the terminology.

Basically I am trying to add a pair of [[ and ]] to a string ( in Visual Studio 2015 using VB), the [[ at the beginning and the ]] at the end, but only if the user has put something into the string, if its blank the [[ ]] aren't needed and will throw up errors with what I'm doing if they're present.

Any advice is greatly appreciated!

Edit: Here is what I tried

If txtDamage.Text = "" Then
dMacro1 & txtDamage.Text & dMacro2
txtDamage.Text = " "
End If

Answer Source

After reading your post several times I guess I have an idea what you want.

If Not txtDamage.Text = "" Then
   txtDamage.Text = "[[" & txtDamage.Text & "]]"
End If

This should do it. Correct me if I interpret your question wrong.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download