Author Topic: Copy same value to another label text  (Read 1219 times)

Padex

  • Newbie
  • *
  • Posts: 11
    • View Profile
Copy same value to another label text
« on: March 06, 2017, 10:58:32 PM »
Hi Guys,
Pls advice....
How to create vb code to copy label1 = label2, label2 = label3, label3=label4..... with difference value..
Fyi, label1 is data result.. this value always change after press enter button.
I need  copy like array index and publish in line chart
Example:
Current value
label1 = 0.001
label2 = 0.002
label3 = 0.003
label4 = 0.004

After push button enter
label1= 0.005
label2= 0.001
label3= 0.002
label4 = 0.003


Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5317
    • View Profile
    • AdvancedHMI
Re: Copy same value to another label text
« Reply #1 on: March 11, 2017, 08:46:44 PM »
If you need to loop through the labels like an array, you are going to have to create an array of labels and point the elements to each label.
Code: [Select]
Private LabelArray(4) as Label

Private Sub OnLoad(.....
  LabelArray(0)=Label1
  LabelArray(1)=Label2
  LabelArray(2)=Label3
  LabelArray(3)=Label4
End Sub

You can now use the array elements to access the labels.
Code: [Select]
For i=LabelArray.Length-1 to 1 Step -1
  LabelArray(i).Text=Label(i-1).Text
Next