Control arrays... the loss of (index As Integer)

J

John

Hello everyone,

I'm currently writing a program to keep track of schedule changes at a
school. The goal is to have someone using the program to declare changes,
then the program writes a html file, which is uploaded to a webserver. Then
students and teachers can view it online, but there are also a couple of
computers with 19" monitors standing around the school to display the
webpage (IE kiosk mode).

The program has a form containing a tab control. It holds one tabpage for
each day of schedule changes (students need to be able to know of schedule
changes at least one day ahead of time, javascript on the webpage will
autoredirect after a few seconds to make sure all pages can be viewed). Each
tabpage contains several textboxes in which the scheduler can type the
changes, as well as a few checkboxes for the html layout, and a button to
write and upload the html file. All tabpages are identical in layout (no
code written yet, in fact the layout isn't completed either, but that's
because I got stuck on the problem described below).

Now obviously I need the same parsing algorythm to parse data into the html
file on each tab, using the text boxes and checkboxes on that tab. I had
originally planned to have all the controls on one tab, copying them and
pasting copies on each new tab. In VB 6 this would have given me control
arrays of each box, with the index numbers corresponding to the tabpage
index number (first tab having index 0, second index 1 etc.). This would
make sure I only needed 1 very simple procedure to write the HTML:

Sub Button1_Click(index as Integer.... etc.)
Open test.html For Output As #1
Write(1, textbox1(index).text)
Write(1, textbox2(index).text)
If Checkbox1(index).Checked Then
Write(1,SomeHTMLCode)
Else
Write(1,OtherHTML Code)
End If

etc.
End Sub

I guess you already guessed where the glitch is: control arrays no longer
exist in VB .NET 2003. So basically I'm lost. I don't want to create
tabpage-specific coding, especially because that's gonna make it a hell of a
lot harder to add and remove tab pages with the exact same controls
(something which was extremely easy in VB 6). Plus it's gonna be very ugly
and bulky, as you need n times as much procedures, n being the number of
tabpages... so yeah, I'm pretty much lost.

I read up on some of the articles replacing the control arrays with
collections. Will they do the job? That is, can I use them to write common
handlers using indexes to keep track which control fired up the event and
use the same indexes with the textboxes etc. etc.? If so, how? Any
recommended reading?

Any help much appreciated,

John
 
H

Herfried K. Wagner [MVP]

Jeff,

* "Jeff Johnson said:
Newsgroup searches are a good thing*. A thread was just recently posted
called "control arrays." Here's a link that was provided in one of the
replies:

http://msdn.microsoft.com/vbasic/us...library/en-us/dnadvnet/html/vbnet05132003.asp

Some additional links on this topic I have collected over the time:

Creating Control Arrays in Visual Basic .NET and Visual C# .NET:
<URL:http://msdn.microsoft.com/library/e...ngControlArraysInVisualBasicNETVisualCNET.asp>

Getting Back Your Visual Basic 6.0 Goodies
<URL:http://msdn.microsoft.com/library/en-us/dnadvnet/html/vbnet05132003.asp>

WinForms Controls--Creating Control Arrays in VB.NET
<URL:http://www.devx.com/vb2themax/Article/19907/>

Control Array
<URL:http://windowsforms.net/default.aspx?tabindex=5&tabid=47&ItemID=16>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top