|
-
Oct 13th, 2009, 02:17 PM
#1
Thread Starter
New Member
-
Oct 13th, 2009, 02:39 PM
#2
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.
-
Oct 13th, 2009, 03:43 PM
#3
Thread Starter
New Member
Re: Form of frustration :)
Hello There LaVolpe,
Many thanks for your reply 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
-
Oct 13th, 2009, 04:27 PM
#4
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.
-
Oct 14th, 2009, 02:43 PM
#5
Thread Starter
New Member
Re: Form of frustration :)
Hi all,
Just to give you an update on what I did with the help of LaVolpe.
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|