Download Software Development
Transcript
STANDARD ALGORITHMS AND ARRAYS Stage 3 – Implementation • • • • Start a new Visual BASIC project Create a form as above Name the command button cmdDataEntry Enter the code for the command button (declaring all required variables) • Save the project and form in a new folder. Stage 4 – Testing Test the program with some normal test data. You might well be thinking that this is a very tedious example, and that there should be an easier way of implementing the program... ...and you are right! You should be thinking ‘Loop!’ This is an ideal situation to employ a For ... Next loop, as the same action has to be repeated five times. Here is simpler version using 2 For..Next loops: Private Sub cmdDataEntry_Click() Dim student_name as String Dim mark as Integer Dim i as Integer Note: we can’t call the variable ‘name’ as ‘name’ is a VB object property, so we use ‘student_name’ instead. For i = 1 to 5 Student_name = InputBox(“Enter a name”) mark = InputBox(“and their mark”) Next For i = 1 to 5 Form1.Print student_name; mark Next End Sub Implement and test this new version. SOFTWARE DEVELOPMENT (INT 2, COMPUTING) 145