YoungMogul
YoungMogul

Reputation: 101

Operator '<=' not defined for types 'Integer' and 'System.Windows.Forms.TextBox'

Here is the code I am trying:

If txtMonths >= 1 And txtMonths <= 6 Then
    additionalDiscount = 0

Upvotes: 0

Views: 2454

Answers (1)

Mureinik
Mureinik

Reputation: 311853

intMonths is a TextBox, not an int, so you can't just use it as an int. You'd have to extract its textual value and convert it to an int first:

Dim intMonthsVal As Integer = Integer.Parse(txtMonths.Text)
If intMonthsVal >= 1 AndAlso intMonthsVal <= 6 Then
    additionalDiscount = 0
End If

Upvotes: 4

Related Questions