运营商'< ='未定义类型'整数'和' System.Windows.Forms.TextBox'

时间:2015-10-07 23:26:24

标签: vb.net syntax-error

以下是我正在尝试的代码:

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

1 个答案:

答案 0 :(得分:4)

intMonthsTextBox,而非int,因此您无法将其用作int。您必须提取其文本值并首先将其转换为int

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