WhichWayToSanJose WhichWayToSanJose -4 years ago 205
Vb.net Question

If Statements using Decimal Data Type

I have an If statement in which I need to check if a decimal number is less than or equal to 4. I planned to do so using this code, which I will paste for some clarity:

Dim handicap As New List(Of Decimal)
For i = 0 To handicap.Count - 1
If handicap.Item(i) <= 4 Then
End If
Next i

However, I cannot compare the decimal to the integer type. Is there a way I can do this?

Answer Source

Try If handicap.Item(i) <= Convert.ToDecimal(4) Then

or If handicap.Item(i) <= 4D Then

Read more on https://msdn.microsoft.com/en-us/library/xtba3z33.aspx

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download