Trying to make a variable global

I used realBasic back in 2008 but I haven’t done anything in it since so unfortunately, I’ve forgotten a lot.

Basically, I have a window with two buttons. I’m trying to perform an action using button2 which references a variable (an array) Dimed in button1. But button2 doesn’t know anything about button1. I remember the solution had to do with adding a module and setting the properties to “global.” Then I seem to remember Diming the variable (in this case, an array) in the module. But I keep getting the error; “This item does not exist.” Here’s what I have so far:

Action in button1:

Dim name As String = TextField1.Text
newNames.Append(name)

Action in button2:

For i As Integer = 0 to newNames.Ubound
MsgBox(newNames(i))
Next

In the module:

DIM newNames() As String

Thanks!
–Rob

Hi Ron, you need to add a property in the module with scope “Gobal”. Did you do that? There is no Dim command in the module.
You could also add a property to the Window.

best, Thomas

Thanks for the reply Thomas. Yes, I added a property in the module and set it’s scope to global and even tried running it with no Dim command in the module and it still wasn’t working. But your reply got me thinking; maybe in the ‘name’ field, I should put “newNames().” I did that and voila!

Thanks again Thomas,
-Rob