-1

I'm trying to recall something from my brain from 6 years ago but I can't find it and the standard searches aren't bringing me joy.

I have a label like this:

Hello, this is my label and the value of the thing is: #value#. The label continues for a while here.

I need to update #value# in this instance with something from a database, however I can't remember how to without re-writing all the text again in the code. I know there's a way to do it, does anyone know this?

Thanks in advance!

0

2 Answers 2

3

If you are replacing existing text in the label, something like:

Dim myValueFromDatabase As String = "" ' Get the value from the database here
myLabel.Text = myLabel.Text.Replace("#value#", myValueFromDatabase)

Alternatively, you could use string interpolation:

Dim myValueFromDatabase As String = "" ' Get the value from the database here
myLabel.Text = $"Hello, this is my label and the value of the thing is: {myValueFromDatabase}. The label continues for a while here."
Sign up to request clarification or add additional context in comments.

2 Comments

Thankyou Martin, I think it was interpolation I was thinking of, though replace does look rather neat here. Appreciate your help!
Now done! Thanks again
0

$"Hello, this is my label and the value of the thing is: {value}. The label continues for a while here."

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.