[RESOLVED] Form of frustration :)
Hi all,
I created an array like this on form 1
Dim bigFeet(1 to5) As String
On form one I placed a textbox
Then I toddled along and opened up another form,on which I placed
a list box and a command button.In the List items I just placed a,b,c ect
I was trying to use form 2 to place a value into the array in from 1:sick:
I then put this code within the command button event in form 2
If Form2.List1.Text = "a" Then bigFeet(0) = "pigs Alive"
Form1.Text1.Text=bigFeet()
the idea was to pass "pigs alive" to bigFeet element,then publish it to the world in Text1.
The brilliant idea was that I could fill an array thingy from another form.
But the brilliant plan didn't work:eek2: and if I see this message one more time.."Sub or Function not defined.". I will sell go and live in the North Pole(well until it melts anyway:D
Can any of you supervb brains help me out on what is problem.:afrog:
Kind Regards
and many salutations peace and love to all:)
Tom
Re: Form of frustration :)
Welcome to the forums.
Normally to share a form's variables with other forms, you would declare the variable as Public on that form. Then to reference that variable from another form, you prefix the variable with the form's name, i.e., Form1.SomeVariable
However, arrays are slightly different as are other things too. You can't do this with arrays. There are workarounds that include creating Public Let/Get properties on the form to access the array, but more hassle than it's worth in my opinion.
A simpler solution, which can be used for any variable type is to use a bas module. Add a module (not class module) to your project if not already there. Add this to the module: Public bigFeet(1 to 5) As String (also remove it from your form). Now you can access bigFeet() from anywhere in your project. This is true with all Public variables declared in a module.
Re: Form of frustration :)
Hello There LaVolpe,
Many thanks for your reply:wave: and thank you for welcoming me to the forums.
I appreciate your reply and will endeavour to undertake your instructions.
Again many thanks.
Kind Regards
Tommy
Re: Form of frustration :)
Now that we've helped you, you can help us by marking the thread as resolved. If you have JavaScript enabled you can do that easily by pulling down the Thread Tools menu and selecting the Mark Thread Resolved item. Also if someone has been particularly helpful you have the ability to affect their forum "reputation" by rating their post. Only those ratings that you give after you have 20 posts will actually count, but in all cases the person you rate will see your rating and know that you appreciate their help.
Re: Form of frustration :)
Hi all,:wave:
Just to give you an update on what I did with the help of LaVolpe.:thumb:
I created two forms and a module.
On the forms I placed a listbox,and textbox and a command.
In the module I placed the following code
Public Sub ello()
Dim bigFeet(1 To 5) As String
If Form2.List1.Text = "1" Then bigFeet(1) = "sausage"
If Form2.List1.Text = "2" Then bigFeet(1) = "brecon beacons"
Form1.Text1 = bigFeet(1)
End Sub
All I did then was place ello in the command procedures code and bob's uncle!! works a treat,and enables me to do what I wanted to do originally..use one form to enter a value into an array on another form.
Thanks again.
Tommy