Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I have a program that needs to have

Status
Not open for further replies.

BigBart

Programmer
May 12, 2012
4
US
I have a program that needs to have controls identified as a two deminsional array. An example is a BINGO card where each number on the card is a text or label control and has an name ID of a row and a column...much like cells in Excel. Can this be done? I can nwork around it and program it in a funky fashion, but it will not be eloquent with For..Next loops.

Second. I have a frmMain screen for startup. This gets a list of who is attending the Bingo game. When I call the BINGO form from the main form, it spends several seconds generating a bingo card full of controls for each player at the game. Can I generate the person's bingo card in the background while I am in the Main form adding to people to the game as they sign in? Then just turn form to visible when I call it. What will this do to memory, performance, etc.?
 
What have you got so far?

Please tell us where you are stuck.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
I have to create a row of text boxes dynamically for each person playing in my game. This is on screen 2. Screen 1 is a list of those people who show up for the game and assigns them a table. Each person gets a row on screen 2 showing their past scores. For now, I now use a control I created on screen 2 called txtScore(0) I use it as a "seed" control. When I enter Screen 2, I dynamically create the correct number of txtScore() controls based upon the number of scores this person has made in the past. I use: Load txtScore(i) to make a copy of the txtScore(0) in a For-Next loop.

Now I want to change txtScore(0) to txtScore(0,0) so I can put multi people on the screen instead of just one. I don't know how to create this new two-dimensional arr. That is problem 1.

Problem 2: When everyone has arrived and I need to show the txtScores form, it takes several seconds for the form to dynamically create all the text boxes on the screen and show the form. I don't know if the time is spent creating the controls or swapping memory to unload screen 1 and load screen 2. I thought I could create the txtScore(i) controls required for each person as they arrive and are added to the Screen 1 by creating them invisibly on screen 2. Then change the screen 1 to invisible and screen 2 to visible when I am ready for it. Not sure how memory is handled in VB6. Would this be worth the effort?
 
I don't know how to create this new two-dimensional arr
Have you looked at VB Help on arrays?

You have not displayed any of the code where this issue is processed.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
You need to have your data in an array (DataArray(100,100) and and calculate a single number for the text box index from the two elements of the data array.
You cant have the index for the control in more than one dimension but you could have the first lot atarting at 1 and the second at 10 third at 20 so all you have to do is multiply the index by the (person-1) to indicate which person boxes are used

When showing a grid, for speed, put the text boxes in an invisible indexed frame and only show the frame when the last box is created.You can dynamically load the text boxes at run time by starting with one invisible text box indexed to 0. It should show instantly on a reasonable computer.

To create a say 7 x 5 grid Bingo grid say you use -
a=0 (or 36 for second set etc)
For h=0 to 6
For v=0 to 4
a=a+1
Load txtBox(a)
txtBox(a).text= Your data whatever -
txtBox(a).move h*1200,v*1200,1000,1000
txtBox(a).visible=true
Frame1.visible=true

This creates 35 boxes
For a subsequent set of buses just start "a" at 36 and have the data in arrays also starting at 36. Put each grid in a different frame. You could have many frames with some hidden.

 
Sounds like a good case for a UserControl that can deal with the mapping between (row, col) and control array index.

Hard to imagine that generating a card "takes seconds" and needs to be handled as some sort of background task.
 
Thanks, Ted. Some excellent ideas.

I agree about the time, dilettante. However, I can count to two while I go from the main screen to the results screen. This is on a laptop using Vista. It is very fast with windows 7 on my desktop. Leads me to think it is memory management.
 
Um, no. It probably isn't tree spirits either.

Speed can be related to memory but more likely you just have some really slow code. Use a profiler and it may open your eyes pretty wide.
 
I suspect I have gotten into some loops not really needed. Thanks for the reply. I will check this out.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top