Changing a String item in a String Array

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 


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.

Hi Kem

It a byproduct of the similar problem. Here is a picture of the original code from the Xojo Editor.

Remove the extra “.”:

strNote2(2) = “F#”


Hi Tim

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)

1 Like

Ok I got it. Stupid me. I need to take a break! My brain is stuck on some other kind of syntax. Thanks

Happens to us all.

Er, not me, of course. I mean it happens to everyone else but me. Never me. Obviously.


1 Like

Once I thought I made a mistake. Turns out I was wrong.



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.

1 Like

Can someone please change the title ‘itme’ to ‘item’ for future readers, it’s doing me in!


It looked like wront time to me, not item ! :weary:

Sorry for the typing error. I tried to fix it but couldn’t. Thanks to who ever did for me.

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.

`single line`