[Year 12 SofDev] control array type stuff in vb2010

Don Morelli (Optus) da_morelli at optusnet.com.au
Tue May 24 19:43:20 EST 2011


Mark, I had the same issue with the control arrays last year and apparently
you can do it but it is done very differently. 

I have only ever programmed in VB6 and am not familiar with VB2010 and have
managed to avoid it thus far. However, what you said made me revisit my
earlier problem. It appears as though you can't add the control array at
design time, but do it at run time by creating and adding the controls to
the form. I looked up some stuff on the web and found something that may
help-although I really don't know enough about it and I am sure that there
are others on the  list that know how to do this with bells on and could
explain this much better.

 

I have attached a zip file called LikeControlArray. It adds an array of
buttons to a form (called btnMine_(i)) and there is one event handler that
handles all of the buttons-shown below. 

 

Private Sub btnMine_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnMine.Click

        txtClick.AppendText(sender.Text())

    End Sub

 

The bit I can't understand is that I have to add a button called bntMine to
the form at design time so that I can use btnMine.Click  as the handled
event, but the buttons that I add when the form loads are all called
btnMine_(i) .I have no clue about this.

 

I also added some checkboxes which you can process via a loop to see if they
are checked, similar to what you had mentioned.

I hope this helps and that someone else on the list can explain the button
thing that I mentioned above.

I was interested as I got the kids to do a hangman program in VB6 and it
used control arrays and I was interested in doing it in VB2010.  

 

Cheers 

Don Morelli

 

From: sofdev-bounces at edulists.com.au [mailto:sofdev-bounces at edulists.com.au]
On Behalf Of Mark KELLY
Sent: Tuesday, 24 May 2011 1:47 PM
To: Year 12 Software Development Teachers' Mailing List
Subject: [Year 12 SofDev] Assessor's report

 

Hi folk.  Sorry for posting about the ITA assessor's report to this list. I
hope I didn't confuse you too much.

I've had SD on the brain recently* and forgot the complaint was about ITA.

*I'm finally nearly semi-competent in VB2010 and starting to forget my old
VB6 habits, but I certainly miss control arrays. 
Why MS ditched them I'll never know.  It use to be SO easy to loop through
an array of controls and do things with them, e.g. 

For i =1 to 99
  checkbox(i).checked = false
next

Sadly, you can't do that easily any more.

-- 
Mark Kelly
Manager of ICT, Reporting, IT Learning Area
McKinnon Secondary College
McKinnon Rd McKinnon 3204, Victoria, Australia
Direct line / Voicemail: +613 8520 9085, Fax +613 9578 9253
kel at mckinnonsc.vic.edu.au
VCE IT Lecture Notes: http://vceit.com
Moderator: IT Applications Edulist

Want a good time? Call 0112358. Ask for Mr Fibonacci.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.edulists.com.au/pipermail/sofdev/attachments/20110524/e7f9e245/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: LikeControlArray.zip
Type: application/x-zip-compressed
Size: 83021 bytes
Desc: not available
Url : http://www.edulists.com.au/pipermail/sofdev/attachments/20110524/e7f9e245/LikeControlArray-0001.zip 


More information about the sofdev mailing list