|
-
Jan 25th, 2002, 09:59 PM
#1
Thread Starter
Lively Member
Label Arrays.......Moving Text?
Just wondering if its possible to move text from an array of labels
to another array of labels in a certain order.?
for example, this is what i somehow want to do:
Label1(0).Caption = Label2(0).Caption
but when i try to put this line in as well:
Label1(1).Caption = Label2(0).Caption
only the 2nd line works, does this make sense, and if so how do i do it properly?
-
Jan 25th, 2002, 10:07 PM
#2
PowerPoster
It would be quicker if you used loops somehow:
Code:
For i = 0 to (Label1.Count - 1)
Label1(i).Caption = Label2(0).Caption
Next i
What you have written will set the caption of both Label1(0) and Label1(1) to that which is in Label2(0).Caption property.
Is that what you want to happen?
-----------------------------------------
-RJ
[email protected]
-----------------------------------------
-
Jan 26th, 2002, 05:17 PM
#3
Thread Starter
Lively Member
No, not really, what I want to do is to be able to click on -
Label1(0).Caption and move its contents to Label2(0).Caption
or then to be able to click on-
Label1(1).Caption and move its contents to Label2(0).Caption as well, and so on. Both Label1 and Label2 are Arrays.
-
Jan 26th, 2002, 05:22 PM
#4
Hyperactive Member
You should change the assignment order
Label2(0).Caption=Label1(0).Caption
-
Jan 26th, 2002, 05:54 PM
#5
Thread Starter
Lively Member
Ta joijo,
But if I type this
Private Sub Label1_Click(Index As Integer)
Label2(0).Caption=Label1(0).Caption
Label2(0).Caption=Label1(1).Caption
End Sub
Even if I click on Label1(0) only the contents of Label1(1) is written into Label2(0)
-
Jan 26th, 2002, 05:58 PM
#6
Hyperactive Member
Label2(0).Caption=Label1(index).Caption
-
Jan 26th, 2002, 06:16 PM
#7
Thread Starter
Lively Member
Excellent, Ta once again joijo,
Just 1 more problem, is there a way to determine where the
text is going, because Label2 is an array also e.g:
Label2(1).Caption = Label1(1).(Index).Caption
-
Jan 26th, 2002, 06:19 PM
#8
Hyperactive Member
For example you can send the text to theitem of label2 array with the same index as the label clicked
Label2(index).Caption=Label1(index).Caption
-
Jan 26th, 2002, 06:51 PM
#9
Thread Starter
Lively Member
What do I do if I want to send it to a different index?
-
Jan 26th, 2002, 07:03 PM
#10
Hyperactive Member
Put the label number wher you want to send it instead of index.
For example if you want to send in order to the array label
VB Code:
Label2(count).Caption=Label1(index).Caption
count=count+1
First time you click the label the text will be sent to Label2(0), second time to Label2(1) and so on.
This is only an example, now you must make your code according what you want to do
-
Jan 26th, 2002, 09:46 PM
#11
Thread Starter
Lively Member
I must be doing something wrong, i tried-
Label2(count).Caption=Label1(index).Caption
count=count+1
But an error message came up saying-
Cant assign to read only property
and count is highlighted.
Maybe im not explaining myself properly, I have 2 sets of arrays
Label1(0), Label1(1), Label1(2),Label1(3), Label1(4)...etc.. and
Label2(0), Label2(1), Label2(2),Label2(3), Label2(4)...etc..
So.. how do I move text from Label1(0) and Label1(1) into
Label2(0)
Then I want to move text from Label1(2) and Label1(3) into
Label2 (1)
Is this possible....Please Help me... Ta
-
Jan 27th, 2002, 02:06 AM
#12
So.. how do I move text from Label1(0) and Label1(1) into
Label2(0)
Then I want to move text from Label1(2) and Label1(3) into
Label2 (1)
Label2(0).Caption = Label1(0).Caption & Label1(1).Caption
Label2(1).Caption = Label1(2).Caption & Label1(3).Caption
-
Jan 27th, 2002, 06:42 AM
#13
i think that the count way is what you need but i suggest you change the Count variable to another name like Number and you must declare it so
VB Code:
Static Number
Label2(Number).Caption=Label1(index).Caption
Number=Number+1
-
Jan 27th, 2002, 09:16 AM
#14
Thread Starter
Lively Member
Thanks Guys, this seems to work for me now though:
Select Case Index
Case 0
Label2(0).Caption = Label1(0).Caption
Case 1
Label2(0).Caption = Label1(1).Caption
Case 2
Label2(1).Caption = Label1(2).Caption
Case 3
Label2(1).Caption = Label1(3).Caption...etc......
Is there a better way?
or whats the better way?
-
Jan 27th, 2002, 10:01 AM
#15
Hyperactive Member
This is a shorter code to do what you want
VB Code:
Dim number As Integer
number = Int(Index / 2)
Label2(number).Caption = Label1(Index).Caption
label1 stored in label2
---0-------------------0
---1-------------------0
---2-------------------1
---3-------------------1
---4-------------------2
---5-------------------2
---6-------------------3
---7-------------------3
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
|