Hello
I want to change string item 1 in a string array with a PopUpMenu from “B” To “B#” or “B@”. Keep getting a syntax error for strItem (1) = “B#” and strItem (1) = “B@”. What is the correct Syntax or is there a better way to do it?
Thank You
type or paste code here
Dim ChangeItem As String
PopUpMenu.DeleteAllRows
PopUpMenu.AddRow("@")
PopUpMenu.AddRow("#")
ChangeItem = PopUpMenu.Text
Dim strItem ( ) As String = Array("A", "B", "C")
Select Case ChangeItem
Case "#"
strItem (1) = "B#"
Case "@"
strItem (1) = "B@"
End Select
MessageBox("Item 1 " + strItem(1))
(Please use the code tags when posted code to help us help you.)
I pasted your code (mostly) into a test project and it worked just fine once I replaced the curly quotes with straight quotes. I don’t know if that’s in your original or a byproduct of how you posted the code, but I’m guessing the former.
Sorry, I’m not sure what you mean. I thought all strings must in Quotes. What extra do I remove? Do you mean that I have to remove the original string item before I replace it?
strNote2(2) = " "
strNote2(2) = “F#”
Look at Tim’s message again. He quoted what you typed, then posted the correct version. You have a dot between the variable name and opening parenthesis that shouldn’t be there.
strNote2 . (2) → strNote2 (2) (spaces added for emphasis)
I’ve found a lot of code copied from these boards always comes into Xojo with curly quotes for some reason - it’s happened enough that I wrote a Code Assistant to fix them after I paste it in.
Same for me. I’ve not yet searched where the problem is (is it the forum software that converts quotes as one posts, or it’s once you copy the text?). If that is fixable by Xojo, it’d be good.
It’s because users aren’t properly formatting their code using either backticks (surrounding with single for one line or triple for block) or the </> Preformatted text button in the toolbar, so quotes get converted. We had a formatting article around here somewhere, I thought, from when the forums were first converted to Discourse, but I can’t find it at the moment.