loop

xelonite84
12-10-2003, 09:04 AM
is there a way of using a loop behind a button so that when i click it to show an invoice it checks labels such as total subtotal VAT etc on 1 form and then puts them in labels on another form?

and if so how would i go about this? prefereably as easy and as simple as possible

Iceplug
12-10-2003, 09:08 AM
Put the labels in a control array if you really want to do a loop.
But if you are only going to copy them to another form, then:
Form2.Total.Caption = Form1.Total.Caption
for all of the labels.

To make a control array, you have to change all of their names to the same value in the order that you want the indices of the array to be located.
But then you'd be able to use a For Loop :).

xelonite84
12-10-2003, 09:10 AM
would i have to change the names of the labels on the form im copying from? or just the 1s im copying to?

Iceplug
12-10-2003, 09:13 AM
If you are using a control array, yes.
But the name of the control array on Form2 can be different from the name of the control array on Form1 (don't know why you'd make them different, though) :)

xelonite84
12-10-2003, 09:15 AM
no i cant change them on the 1st form there is too many and that form1.lblwhatever.caption code i cant use that i need to use a loop in my code and i just thought i could use 1 doing that

Iceplug
12-10-2003, 09:19 AM
Well, I don't know why you *need* to use a loop if you can't change the control names.
Perhaps you can use a For Each Loop on the controls collection.
Dim ctl As Control
For Each ctl In Form1.Controls
If TypeOf ctl Is Label Then
End If
Next
ctl is every label on your form inside of the If block. :)

xelonite84
12-10-2003, 09:22 AM
ok thanks ill have a go trying that code cheers

and the reason it has to be a loop is that its part of my college assignment and it has to have a loop in it

even though the assignemtn can easily be done without :( hes just making it harder
nevermind

cheers

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum