Put the following code in the Form that you want to show the information:
Code:
Public Sub ShowForm(strArray() As String)
Dim counter As Integer
For counter = LBound(strArray) To UBound(strArray)
'strArray() is the array that you pass to the form that you want to display it in. Use price() in the first form (see below)
Print strArray(counter)
'You don't need to increment counter, the For Loop does that for you
'counter = counter + 1
Next i 'You don't have to put the variable name after the Next, but I find it easier to read
End Sub
Put this code into the Form that you use to gather the info. I assume from your post that you stuff all your data into the array called price() in the 1st Form and you want to display the contents of price() in a 2nd Form.
Code:
Private Sub Form_Click()
Call form1.ShowForm(price)
End Sub
Open a new project. Click Project, Add Form. Click Open to choose 'Form'. Open Form1 and add a Command Button. Open Form2 and add a Label. Leave the names of all the controls as what they default to.
Open the Code window for Form1 and delete whatever code is there. Paste this code:
Code:
Option Explicit
Dim price(5) As Double
Private Sub Command1_Click()
Call Form2.ShowForm(price)
End Sub
Private Sub Form_Load()
price(0) = 100
price(1) = 225.5
price(2) = 300
price(3) = 400
price(4) = 500
price(5) = 600
End Sub
Open the Code window for Form2 and delete whatever code is there. Paste this code:
Code:
Option Explicit
Public Sub ShowForm(dblArray() As Double)
Dim counter As Integer
For counter = LBound(dblArray) To UBound(dblArray)
Label1.Caption = Label1.Caption & dblArray(counter) & vbCrLf
Next counter
Me.Show
End Sub
This will give you an idea of how it works. Now you have to modify the rest to suit your needs.
If you're going to post a question here and expect to get a code example, you have to know how to debug and tweak the code to make it work for you.
Cimperiali is busy, or might be have read the answers you got and thought
they are enough for you to start trying by yourself.
In any case: malleyo helped you a lot, and you should thank
him. Moreover, herearound is full of people who are even better than
"Cimperiali" in writing helpful code, so do not ask for me directly...
As you seem a bit in difficoulty, to help you more, here how it could
be (see the notes I wrote in FrmStart). Note that the way array is passed
is quite the same as malleyo suggested...
Btw:
My wife is having a baby (our first baby), so you will not see me
very often in next days.
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
[...] thank [...]
you all guys are helpful
and i love this forum it is the best
You're welcome
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.