Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Passing an Array between Forms?

Hi folks,

I'm using VBA to create a "Wizard" in Excel. The Wizard is simply a
collection of UserForms.

In the first Form, the user is asked to supply the for names for a
group of items. They do this by typing the names in to a Text Box,
one at a time.

For example, the first name is typed, the user presses an ADD button,
and the Text Box's current value is written to an Array element. The
Text Box is cleared, the user types another name, this is added to the
next Array element, and so on.....

When finished, the user clicks a NEXT button to advance to the next
Form in the Wizard. In this Form, I'd like to present (in a combo-
box) a list of all the elements in the Array. This gives the user a
chance to review their entries, and make corrections if necessary.
And here is my question.......

How can I make the Array from Form1 visible to Form2?

Kind regards,

Jason Paris

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Passing an Array between Forms?

Declare the array as a public variable in a standard code module.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Jason Paris" wrote in message
oups.com...
Hi folks,

I'm using VBA to create a "Wizard" in Excel. The Wizard is simply a
collection of UserForms.

In the first Form, the user is asked to supply the for names for a
group of items. They do this by typing the names in to a Text Box,
one at a time.

For example, the first name is typed, the user presses an ADD button,
and the Text Box's current value is written to an Array element. The
Text Box is cleared, the user types another name, this is added to the
next Array element, and so on.....

When finished, the user clicks a NEXT button to advance to the next
Form in the Wizard. In this Form, I'd like to present (in a combo-
box) a list of all the elements in the Array. This gives the user a
chance to review their entries, and make corrections if necessary.
And here is my question.......

How can I make the Array from Form1 visible to Form2?

Kind regards,

Jason Paris



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Passing an Array between Forms?

Jason,
Whilst I would probably go with Bob's reply in this situation, have you
thought of redesign your UI to either:
- Allow reviewing of entries before the user leaves that form, but maybe you
will still need to pass an array any way..
- Use frames to show/hide the steps of the Wizard on a single userform.

As an alternative to the Public array and if you really want to pass the
array: As forms are really class modules, you can create public
properties/methods for them. e.g.

'<Form 2 code
Dim Form2Array() As String

Public Property Let SetArrayValues(InValues() As String)
Form2Array = InValues
End Property

Public Property Get GetArrayValue(Index As String)
GetArrayValue = Form2Array(Index)
End Property
'</Form 2 code

'<Form 1 code
Private Sub CommandButton2_Click()

With UserForm2
.SetArrayValues = Split(TextBoxInput, vbNewLine)

MsgBox .GetArrayValue(2)
End With
End Sub
'</Form 1 code

NickHK

"Jason Paris" wrote in message
oups.com...
Hi folks,

I'm using VBA to create a "Wizard" in Excel. The Wizard is simply a
collection of UserForms.

In the first Form, the user is asked to supply the for names for a
group of items. They do this by typing the names in to a Text Box,
one at a time.

For example, the first name is typed, the user presses an ADD button,
and the Text Box's current value is written to an Array element. The
Text Box is cleared, the user types another name, this is added to the
next Array element, and so on.....

When finished, the user clicks a NEXT button to advance to the next
Form in the Wizard. In this Form, I'd like to present (in a combo-
box) a list of all the elements in the Array. This gives the user a
chance to review their entries, and make corrections if necessary.
And here is my question.......

How can I make the Array from Form1 visible to Form2?

Kind regards,

Jason Paris



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Passing an Array between Forms?

But the properties method does require that the form stays in memory Nick,
i,e it is not unloaded (I know that you know, but the OP might not).

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"NickHK" wrote in message
...
Jason,
Whilst I would probably go with Bob's reply in this situation, have you
thought of redesign your UI to either:
- Allow reviewing of entries before the user leaves that form, but maybe
you
will still need to pass an array any way..
- Use frames to show/hide the steps of the Wizard on a single userform.

As an alternative to the Public array and if you really want to pass the
array: As forms are really class modules, you can create public
properties/methods for them. e.g.

'<Form 2 code
Dim Form2Array() As String

Public Property Let SetArrayValues(InValues() As String)
Form2Array = InValues
End Property

Public Property Get GetArrayValue(Index As String)
GetArrayValue = Form2Array(Index)
End Property
'</Form 2 code

'<Form 1 code
Private Sub CommandButton2_Click()

With UserForm2
.SetArrayValues = Split(TextBoxInput, vbNewLine)

MsgBox .GetArrayValue(2)
End With
End Sub
'</Form 1 code

NickHK

"Jason Paris" wrote in message
oups.com...
Hi folks,

I'm using VBA to create a "Wizard" in Excel. The Wizard is simply a
collection of UserForms.

In the first Form, the user is asked to supply the for names for a
group of items. They do this by typing the names in to a Text Box,
one at a time.

For example, the first name is typed, the user presses an ADD button,
and the Text Box's current value is written to an Array element. The
Text Box is cleared, the user types another name, this is added to the
next Array element, and so on.....

When finished, the user clicks a NEXT button to advance to the next
Form in the Wizard. In this Form, I'd like to present (in a combo-
box) a list of all the elements in the Array. This gives the user a
chance to review their entries, and make corrections if necessary.
And here is my question.......

How can I make the Array from Form1 visible to Form2?

Kind regards,

Jason Paris





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA passing information between differnt User Forms chfa Excel Programming 6 March 27th 07 11:58 AM
Passing a Forms Control to Function Pflugs Excel Programming 5 August 24th 06 10:34 PM
passing variables between 2 forms burl_rfc Excel Programming 3 April 14th 06 05:49 AM
Passing variables between forms Sami82[_8_] Excel Programming 7 October 8th 05 12:12 AM
User Forms - passing data between them mickiedevries Excel Programming 3 June 21st 04 08:59 PM


All times are GMT +1. The time now is 12:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"