So I found this tid-bit → Multiple Label Lines Hoping it would answer my question and solve the problem.
I have a label that is set for multiple line and index 0 = “Start” Index 1 = “Lunch”
Using this code: Dim tempLabel() As String = Split(Label1.text, EndOfLine) tempLabel(1) = "Replacing the second line." Label1.text = Join(tempLabel, EndOfLine)
I adapted and failed with this code… strTmpLbl = Split( lblBtnStartEndLunch.Value.ToText, EndOfLine ) strTmpLbl( 0 ) = "Start" lblBtnStartEndLunch.Value.ToText = Join( strTmpLbl, EndOfLine )
I get a Syntax Error and not other information to help decipher what I did wrong…
When I try the lblBtnStartEndLunch.Text I still get a Syntax Error. I followed the example but used what I know to work for other instances when I assign a value to a Label. But those are usually just a single line or word.
The .Text option doesn’t appear either. And lblBtnStartEndLunch is the name of the object.
Do you actually dim (or var) strTmpLbl? And as what? A String? Or an Array of Strings? Because you try to stuff an array of strings into it (the result of the Split method).
the above code is not mine, I got it from here → Multiple Label Lines - #3 by Bob_Manning Bob Coleman posted it. I copied it and changed the variable to meet my needs and… there is a Syntax error.
Well, in the first place that thread is ridiculous. Getting the text, try to split it, try to replace one of the array elements…
Just have an array already as a property of the window or a subclass of the label, add a method ReplaceLine(NewText As String, Line as Integer) and in there replace the item and then change the Caption using the Array.Join function
No, it’s a Label that has the property Multiline enabled, I want to change one line of the Label to reflect what is happening in the application at the time.
You must be on one of those weird transitional releases between 2019 and 2020r1 where everything was messed up. They reverted back to sanity in 2020r2.
Edit: if you type in .Text it should also work. You won’t get autocomplete and you’ll get a deprecation warning in Analyze Project, but it should still compile and run. And you’ll be future-ready should you decide to upgrade to the current release.
Edit2: The property was .Text for the last 20 years. In 2019r2 they made the ill-advised decision to change it to .Value. In 2020r2 they finally changed it back.