Why this code doesn’t work?
it returns an unexpected value actually total = 0.
total = Cscore(TextBox1.Text) * CDbl(TextBox2.Text)
when trying this
total = TextBox1.Text * TextBox2.Text
it returns the expected value but I need to pass textbox1.text to the function to get the desirable value
the function is this
Public Function Cscore(ByVal score As Integer) As Double
Select Case score
Case score = 100
Return 5.0
Case score >= 95
Return 5.0
Case score >= 90
Return 4.75
Case score >= 85
Return 4.5
Case score >= 80
Return 4.0
Case score >= 75
Return 3.5
Case score >= 70
Return 3.0
Case score >= 65
Return 2.5
Case score >= 60
Return 2.0
Case score < 60
Return 1.0
End Select
End Function
thanks in advance
Using Option Strict On would have helped you quickly find the problem. Your syntax for the Case statements is wrong, those expressions evaluate to Boolean. score will rarely be equal to True or False, you only get a value if score equals 0 or 1. You need to write it like this:
Use Option Strict On while you learn to program in VB.NET. You can turn it off again when you’ve become a master.