Task Time, Page 4
Creating a practical project.
Before you continue, I'd like to set you a little task. Try doing this - create a form and add a command button ("cmdStudentEntry") and list box ("lstStudents"). In the code behind the command button, prompt the user "How many students do you want to add?" - and then displays that number of input boxes to accept student names, adding each to the list box.
Now don't read below before you attempt the task. Oooh, I know it's tempting. But don't. No! NO!! Stop it. Stop right there, sonny. I've been around the world a bit and have got your number. Nudge, nudge, wink, wink. Ooh la la, folly de lay! Yah, boo, sucks to you.
Dim NoOfLoops as IntegerDim StudentName as String' Dim a couple of variables to hold informationNoOfLoops = InputBox("How many students do you want to add?")' Ask user how many times to loop aroundFor i = 1 to NoOfLoops' Tell Visual Basic how many times to loopStudentName = InputBox("Enter a student name:")' Put student name into StudentName variablelstStudents.AddItem (StudentName)' Add the name stored in StudentName to the list boxNext i
Page 4 of 7