Write a program in visual basic that accepts a name and a score of six students in a test
through the use of inputbox(). The program should then display the names, scores and the average scores on a picturebox. Attach the code to a command button


Answer:

Private Sub btnDisplay_Click()
Dim names(5) As String
Dim scores(5) As Double
Dim totalScore As Double
Dim averageScore As Double
Dim i As Integer

' Loop to accept names and scores for six students
For i = 0 To 5
names(i) = InputBox("Enter name for student " & (i + 1) & ":")
scores(i) = Val(InputBox("Enter score for " & names(i) & ":"))
Next i

' Calculate the total score
totalScore = 0
For i = 0 To 5
totalScore = totalScore + scores(i)
Next i

' Calculate the average score
averageScore = totalScore / 6

' Display names, scores, and average score on the PictureBox
picDisplay.Cls
picDisplay.Print "Name", "Score"
picDisplay.Print "-------------------"
For i = 0 To 5
picDisplay.Print names(i), scores(i)
Next i
picDisplay.Print "-------------------"
picDisplay.Print "Average Score: ", averageScore
End Sub


Share To Friends Via:
        






More Questions For Visual Basic Programming:



  Explain each of the following types of controls in a Visual Basic program (4 marks) (i) DriveListBox (ii) DirListBox (Answered)
Explain each of the following types of controls in a Visual Basic program (4 marks) (i) DriveListBox (ii) DirListBox .
Posted On:Wed 24, July 2024 03:34:54 am
  State the visual basic conversion type function used to convert a string of the following statement in a visual basic program: (4 marks) (i) Boolean data; (ii) Currency; (iii) Date data; (iv) Integer data. (Answered)
State the visual basic conversion type function used to convert a string of the following statement in a visual basic program: (4 marks) (i) Boolean data; (ii) Currency; (iii) Date data; (iv) Integer data. .
Posted On:Wed 24, July 2024 03:36:56 am
  Explain the function of each of the following IDE interface of a visual basic program: (6 marks) (i) Form window; (ii) Property window; (iii) Form layout window. (Answered)
Explain the function of each of the following IDE interface of a visual basic program: (6 marks) (i) Form window; (ii) Property window; (iii) Form layout window. .
Posted On:Wed 24, July 2024 03:38:10 am
  Explain each of the following error handling methods used in Visual Basic programming language (6 marks) i. Err.Number, ii. Err.Clear, iii. On Error-GoTo (Answered)
Explain each of the following error handling methods used in Visual Basic programming language (6 marks) i. Err.Number, ii. Err.Clear, iii. On Error-GoTo .
Posted On:Wed 24, July 2024 03:39:15 am
  Distinguish between function procedure and event procedure as used in Visual Basic programming language. (Answered)
Distinguish between function procedure and event procedure as used in Visual Basic programming language. .
Posted On:Wed 24, July 2024 03:40:35 am
  State two differences between the unload method and Hide method as used in Visual Basic program forms. (Answered)
State two differences between the unload method and Hide method as used in Visual Basic program forms. .
Posted On:Wed 24, July 2024 03:43:27 am
  Write a Visual Basic program that accepts percentage score in an examination through the use of an input box function. The program then displays a remark based on the following criteria. Use case statement. (5 marks) Score remarks 0-40 Failed 41-50 Pass 51-70 Credit Above 70 Distinction (Answered)
Write a Visual Basic program that accepts percentage score in an examination through the use of an input box function. The program then displays a remark based on the following criteria. Use case statement. (5 marks) Score remarks 0-40 Failed 41-50 Pass 51-70 Credit Above 70 Distinction .
Posted On:Wed 24, July 2024 03:44:34 am
  State a circumstance under which each of the following statements are used in a visual basic program: (6 marks) (i) ReDim; (ii) Option base; (iii) Preserve. (Answered)
State a circumstance under which each of the following statements are used in a visual basic program: (6 marks) (i) ReDim; (ii) Option base; (iii) Preserve. .
Posted On:Wed 24, July 2024 03:46:00 am

More Questions Categories:


About Us

Contact us

Terms of use | Privacy policy

Follow Us:               

All Rights Reserved © 2024; pscustudies.com