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


Answer:

Sub Main()
' Declare variables
Dim score As Integer
Dim remark As String
Dim input As String

' Get the percentage score from the user
input = InputBox("Enter the percentage score in the examination:", "Score Input")

' Validate the input and convert to integer
If IsNumeric(input) Then
score = CInt(input)

' Use Select Case to determine the remark based on the score
Select Case score
Case 0 To 40
remark = "Failed"
Case 41 To 50
remark = "Pass"
Case 51 To 70
remark = "Credit"
Case Is > 70
remark = "Distinction"
Case Else
remark = "Invalid score"
End Select

' Display the remark
MsgBox "Score: " & score & vbCrLf & "Remark: " & remark, vbInformation, "Examination Result"
Else
MsgBox "Invalid input. Please enter a numeric value.", vbExclamation, "Error"
End If
End Sub


Share To Friends Via:
        






More Questions For Visual Basic Programming:



  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 (Answered)
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 .
Posted On:Wed 17, July 2024 20:00:28 pm
  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
  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