私はここで質問からできることすべてを調べて、私が試したことは何も問題を解決しました。この関数は、文字グレードをアプリケーションに出力するためのものです。ここでは、クラスと関数のコードを分かりやすくするために示します。どのように解決する '関数はすべてのコードパスで値を返さない'
Public Class Coursegrade
'names private veriables
Private _Score1 As Integer
Private _Score2 As Integer
Private _Score3 As Integer
Private Letter_grade As String
'gets and returns each veriable
'for application use
Public Property Grade As String
Get
Return Letter_grade
End Get
Set(value As String)
If value > String.Empty Then
Letter_grade = value
Else
Letter_grade = String.Empty
End If
End Set
End Property
Public Property TestScore1 As Integer
Get
Return _Score1
End Get
Set(value As Integer)
If value > 0 Then
_Score1 = value
Else
_Score1 = 0
End If
End Set
End Property
Property TestScore2 As Integer
Get
Return _Score2
End Get
Set(value As Integer)
If value > 0 Then
_Score2 = value
Else
_Score2 = 0
End If
End Set
End Property
Public Property TestScore3 As Integer
Get
Return _Score3
End Get
Set(value As Integer)
If value > 0 Then
_Score3 = value
Else
_Score3 = 0
End If
End Set
End Property
'starts veriables of at 0
Public Sub New()
_Score1 = 0
_Score2 = 0
_Score3 = 0
End Sub
'calculates the adverage
Public Function Gettotal() As Integer
Return _Score1 + _Score2 + _Score3
End Function
Public Function Give_letter_grade() As String
Dim intTotal As Integer
intTotal = Gettotal()
'start your secletion
If intTotal <= 270 AndAlso intTotal >= 300 Then
Letter_grade = "A"
ElseIf intTotal <= 240 AndAlso intTotal >= 269 Then
Letter_grade = "B"
ElseIf intTotal <= 210 AndAlso intTotal >= 239 Then
Letter_grade = "C"
ElseIf intTotal <= 180 AndAlso intTotal >= 290 Then
Letter_grade = "D"
ElseIf intTotal > 180 Then
Letter_grade = "F"
Else
Letter_grade = ""
End If
End Function
エラーが所与の手紙グレードの終了機能に
を示してどのように 'intTotal'はこれまで、同時に<270 and > 300することができますか?また、vbaはVB.NETと同じではありません。このメソッド(関数)は何も返さないので、あなたはメッセージを受け取るでしょう。 – Plutonix
あなたはこれを行うことからあなたの期待は何ですか:If value> String.Empty Then –
私はそれがその数値範囲に対して同じ出力を出そうとしていました。 –