Solved

3rd Array question

Posted on 2000-03-23
12
219 Views
Last Modified: 2010-05-02
What is the best way to do this.

On form1 I have an array of 32 textbox
txtValue(0))....txtValue(31)

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).BackColor = &H80FFFF Then
ChkValue(0).value = 1
Else
ChkValue(0).value = 0
End If

If form1.txtValue(1).BackColor =&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
0
Comment
Question by:ptran2000
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 3
12 Comments
 
LVL 28

Expert Comment

by:AzraSound
ID: 2651596
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.
0
 

Author Comment

by:ptran2000
ID: 2651611
Would a loop be faster that a bunch of if statements, I'm really looking for performance.
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2651617
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?
0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 

Accepted Solution

by:
PIBM earned 100 total points
ID: 2651632
For I% = 0 to 31
  If form1.TxtValue(I).BackColor = &H 80FFFF Then
    ChkValue(I).value = 1
  Else
    ChkValue(I).value = 0
  End If
Next I


That does it, and it's the fastest both programming & CPU time consuming way to do it. Can't remove the else or previous values would not be removed
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2651640
Dim i As Integer
For i = 0 to TxtValue.Ubound
If form1.TxtValue(i).BackColor = &H80FFFF Then
ChkValue(i).value = 1
Else
ChkValue(i).value = 0
End If
Next


thats if you want to use a loop
0
 

Expert Comment

by:PIBM
ID: 2651641
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.
0
 

Expert Comment

by:PIBM
ID: 2651647
Azra is the same as mine, except that I used the % to "dim" my variable.
0
 

Author Comment

by:ptran2000
ID: 2651652
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.
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2651665
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).Value = 1
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2651667
yeah sorry bout that PIBM...you type faster than me I suppose
0
 

Author Comment

by:ptran2000
ID: 2651698
Thanks,   PIBM for being the faster typist.
0
 

Expert Comment

by:PIBM
ID: 2651801
hehe thanks for your point, with the question I asked I was down to 1 point. And finally I found out by myself =)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question