ptran2000
asked on
3rd Array question
What is the best way to do this.
On form1 I have an array of 32 textbox
txtValue(0))....txtValue(3 1)
On form2 I have an array of 32 checkboxes
chkValue(0)....chkValue(31 )
When form2 opens it looks at form1 (form 1 is still open)
If form1.TxtValue(0).BackColo r = &H80FFFF Then
ChkValue(0).value = 1
Else
ChkValue(0).value = 0
End If
If form1.txtValue(1).BackColo r =&H80FFFF Then
ChkValue(1).value = 1
Else
ChkValue(1).value = 0
End If
........
Is there a better way to do this, instead of using a bunch of if statements?
thanks much
On form1 I have an array of 32 textbox
txtValue(0))....txtValue(3
On form2 I have an array of 32 checkboxes
chkValue(0)....chkValue(31
When form2 opens it looks at form1 (form 1 is still open)
If form1.TxtValue(0).BackColo
ChkValue(0).value = 1
Else
ChkValue(0).value = 0
End If
If form1.txtValue(1).BackColo
ChkValue(1).value = 1
Else
ChkValue(1).value = 0
End If
........
Is there a better way to do this, instead of using a bunch of if statements?
thanks much
You should look at the examples from your other two questions and note how loops were used and try to do this yourself first and then come here if you cant figure it out.
ASKER
Would a loop be faster that a bunch of if statements, I'm really looking for performance.
well what in your program is making the backcolor yellow anyways? is it set at design time or is it something that happens at runtime?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Dim i As Integer
For i = 0 to TxtValue.Ubound
If form1.TxtValue(i).BackColo r = &H80FFFF Then
ChkValue(i).value = 1
Else
ChkValue(i).value = 0
End If
Next
thats if you want to use a loop
For i = 0 to TxtValue.Ubound
If form1.TxtValue(i).BackColo
ChkValue(i).value = 1
Else
ChkValue(i).value = 0
End If
Next
thats if you want to use a loop
Explication : What is does is looping through all the box using a variable, giving the variable all the values of the textbox one after the other, and checking if that's right or not every times.
Azra is the same as mine, except that I used the % to "dim" my variable.
ASKER
It is set at runtime by a user clicking on it. It serves as an indicator that the value in that control will be changed.
then just add code there and then to set the checkbox value. right where you use that code to change the color just add one more line
form2.chkValue(index).Valu e = 1
form2.chkValue(index).Valu
yeah sorry bout that PIBM...you type faster than me I suppose
ASKER
Thanks, PIBM for being the faster typist.
hehe thanks for your point, with the question I asked I was down to 1 point. And finally I found out by myself =)