[Year 12 SofDev] C# - Adding data to an Array from user input

Darren Scott dscott at ccb.vic.edu.au
Tue Feb 7 08:32:46 AEDT 2017


VB has a Redim command … does C# ?

Something like this?

ReDim Preserve thesecars(0 To thiscar)          ' keep the data, add one to the array of cars
        thesecars(thiscar) = New cars                   ' make a new car
        With thesecars(thiscar)                         ' get info from screen into thiscar
            .id = Val(lblID.Text)
            .make = txtMake.Text
            .model = txtModel.Text
        End With

It’s probably not the cleanest solution …

Darren



[cid:CCBcrest60x63_21f6a3df-1929-4432-add0-6625033709f2.png]
Darren Scott
Teacher
Catholic College Bendigo

'Opening the Doors of Mercy'

La Valla (Yrs 7-9): Ph: 03 5449 3466
Coolock (Yrs 10-12): Ph: 03 5445 9100
Finance Office: Ph: 03 5445 9191



From: sofdev-bounces at edulists.com.au [mailto:sofdev-bounces at edulists.com.au] On Behalf Of Cooper, Michael J
Sent: Monday, February 6, 2017 4:35 PM
To: Year 12 Software Development Teachers' Mailing List <sofdev at edulists.com.au>
Subject: Re: [Year 12 SofDev] C# - Adding data to an Array from user input

Thanks Ben the list methods seem like a much cleaner way to do it

Michael Cooper
ICT Co-ordinator & Network Support

[id:image001.png at 01D2440D.0D6FCCA0]
braybrooksc.vic.edu.au<http://www.Braybrooksc.vic.edu.au>
Ph. 9312 2900


From: <sofdev-bounces at edulists.com.au> on behalf of Ben Hines <b.hines at ccg.vic.edu.au>
Reply-To: Year 12 Software Development Teachers' Mailing List <sofdev at edulists.com.au>
Date: Monday, 6 February 2017 at 2:46 pm
To: Year 12 Software Development Teachers' Mailing List <sofdev at edulists.com.au>
Subject: Re: [Year 12 SofDev] C# - Adding data to an Array from user input

Um,

The problem with arrays is that they are made with a fixed size.

You can easily have a textbox (or NumericInput) control, then a button that adds to the array. You will need to have a counter variable that keeps track of where you are in the array.

Or you could just use a List<T> which has methods for adding and removing from the list (List is just an array with lots of helpful functions that make it easier to use).

Hope that helps!

Regards,

Ben Hines


Ben Hines
Mathematics and ICT Teacher
Senior School - Waurn Ponds
(03)5241 1577

[Image removed by sender. hristian College Geelong]

[Image removed by sender.] Please consider the environment  before printing this email.
From: sofdev-bounces at edulists.com.au [mailto:sofdev-bounces at edulists.com.au] On Behalf Of Cooper, Michael J
Sent: Monday, 6 February 2017 12:58 PM
To: Year 12 Software Development Teachers' Mailing List <sofdev at edulists.com.au>
Subject: [Year 12 SofDev] C# - Adding data to an Array from user input

Hello fellow SD teachers,

C# coding question - what is the best way to allow a USER to enter data into an array using a GUI, not the console?

I’ve used InputBoxes and loops with Visual Basic, however InputBoxes don’t seem to be thing in C#, without adding the Microsoft.VisualBasic namepace.

I can add data to an array during design time easily enough, but I want the USER to be able to click on a button and be prompted to enter data, which then populates the array.

Or am I going about this the wrong way entirely and should be using another technique?

Michael Cooper
ICT Co-ordinator & Network Support

[cid:image005.png at 01D2811C.4A3DB0B0]
braybrooksc.vic.edu.au<http://www.Braybrooksc.vic.edu.au>
Ph. 9312 2900


IMPORTANT - This email and any attachments may be confidential. If received in error, please contact us and delete all copies. Before opening or using attachments check them for viruses and defects. Regardless of any loss, damage or consequence, whether caused by the negligence of the sender or not, resulting directly or indirectly from the use of any attached files our liability is limited to resupplying any affected attachments. Any representations or opinions expressed are those of the individual sender, and not necessarily those of the Department of Education and Training.


________________________________
Message protected by MailGuard: e-mail anti-virus, anti-spam and content filtering.
http://www.mailguard.com.au

Report this message as spam<https://console.mailguard.com.au/ras/1Qd3zTUEZM/1ibn1N2QYL7pAHC9BDIL3b/0>


This e-mail is intended for the use of the named individual or entity and may contain confidential and privileged information. Any dissemination, distribution or copying by anyone other than the intended recipient of this e-mail is strictly prohibited. If this e-mail has been received in error, then please notify Christian College or the author of this email immediately and destroy the original message. We have made every attempt to ensure this e-mail message is free from computer viruses however the attached files are provided on the basis that the user assumes all responsibility for use of the material transmitted. Views, opinions, etc. expressed reflect those of the author and not Christian College nor its associated companies and campuses which includes Eden Quality Services Pty Ltd.
________________________________
Message protected by MailGuard: e-mail anti-virus, anti-spam and content filtering.
http://www.mailguard.com.au



IMPORTANT - This email and any attachments may be confidential. If received in error, please contact us and delete all copies. Before opening or using attachments check them for viruses and defects. Regardless of any loss, damage or consequence, whether caused by the negligence of the sender or not, resulting directly or indirectly from the use of any attached files our liability is limited to resupplying any affected attachments. Any representations or opinions expressed are those of the individual sender, and not necessarily those of the Department of Education and Training.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.edulists.com.au/pipermail/sofdev/attachments/20170206/8360c100/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 9943 bytes
Desc: image001.png
Url : http://www.edulists.com.au/pipermail/sofdev/attachments/20170206/8360c100/image001-0001.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image003.jpg
Type: image/jpeg
Size: 1457 bytes
Desc: image003.jpg
Url : http://www.edulists.com.au/pipermail/sofdev/attachments/20170206/8360c100/image003-0001.jpg 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image004.jpg
Type: image/jpeg
Size: 347 bytes
Desc: image004.jpg
Url : http://www.edulists.com.au/pipermail/sofdev/attachments/20170206/8360c100/image004-0001.jpg 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image005.png
Type: image/png
Size: 12483 bytes
Desc: image005.png
Url : http://www.edulists.com.au/pipermail/sofdev/attachments/20170206/8360c100/image005-0001.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CCBcrest60x63_21f6a3df-1929-4432-add0-6625033709f2.png
Type: image/png
Size: 8501 bytes
Desc: CCBcrest60x63_21f6a3df-1929-4432-add0-6625033709f2.png
Url : http://www.edulists.com.au/pipermail/sofdev/attachments/20170206/8360c100/CCBcrest60x63_21f6a3df-1929-4432-add0-6625033709f2-0001.png 


More information about the sofdev mailing list