参考VBA代码:
Option Explicit
Private Function IsPass(ByVal InputScore As Single, _
Optional ByVal MinScore As Single = 60) As Boolean
IsPass = (InputScore >= MinScore)
End Function
Sub ScoreDemo()
Dim strCourse(1 To 2) As String
Dim blnIsPass(1 To 2) As Boolean
Dim strScore As String
Dim lngK As Long
strCourse(1) = "语文"
strCourse(2) = "数学"
On Error Resume Next
For lngK = 1 To 2
strScore = InputBox("请输入" & strCourse(lngK) & "成绩", vbNullString)
If StrPtr(strScore) Then
blnIsPass(lngK) = IsPass(CSng(strScore))
End If
Next
If blnIsPass(1) And blnIsPass(2) Then
MsgBox "全部及格", , vbNullString
Else
For lngK = 1 To 2
If blnIsPass(lngK) Then
MsgBox strCourse(lngK) & "及格", , vbNullString
End If
Next
End If
End Sub
运行截图:
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/d50735fae6cd7b89e70c5238012442a7d9330e2c?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/4bed2e738bd4b31c2082fc0089d6277f9f2ff8cb?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/43a7d933c895d1432d848c987df082025baf079e?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/8644ebf81a4c510f3b0d8aa16e59252dd52aa544?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/0eb30f2442a7d933b59d8fc8a34bd11373f00157?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/f636afc379310a553d5bb54fb94543a982261009?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/b151f8198618367a7bec146620738bd4b31ce520?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/d4628535e5dde7118d94284da9efce1b9c1661c2?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/242dd42a2834349beb46053ec7ea15ce37d3becd?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)
追问看不懂啊
我就要vba的