【发布时间】:2014-01-22 01:52:10
【问题描述】:
因此,对于这个程序,任务是为汽车租赁公司创建一个程序。不同种类的汽车由单选按钮选择,汽车租赁成本(每天)乘以租赁天数。我已经按照书本做了所有事情,所以有什么问题?它不断出现我编码的消息框,告诉我我输入的数据不是数字(它是)
Dim decJeepWrangler As Decimal = 55D
Dim decLandRover As Decimal = 125D
Dim decPickup As Decimal = 85D
Dim intDays As Integer
Dim decTotalCost As Decimal
Dim decCost As Decimal
If IsNumeric(txtDays) Then
intDays = Convert.ToInt32(txtDays)
If intDays > 0 Then
If radJeepWrangler.Checked Then
decCost = decJeepWrangler
ElseIf radLandRover.Checked Then
decCost = decLandRover
ElseIf radPickup.Checked Then
decCost = decPickup
End If
decTotalCost = intDays * decCost
lblTotalCost.Text = decTotalCost.ToString("C")
Else
MsgBox("You entered " & intDays.ToString() & ". Enter a positive number", , "Input Error")
txtDays.Text = ""
txtDays.Focus()
End If
Else
MsgBox("Enter how many days you will be renting", , "Input Error")
txtDays.Text = ""
txtDays.Focus()
End If
End Sub
【问题讨论】:
-
请准确描述您的代码有什么问题。我们不会做猜测工作,这是承包商通常的工作,他们为此收取高额费用。
-
txtDays的声明未包含在您的帖子中。它是什么?它实际上是文本。等一下!不,因为您调用了它的.Focus()方法,而字符串没有具有.Focus() 事件。您实际上应该阅读代码。 (调试器也会告诉你这一点;你现在应该学会使用它。) -
txtDays 是一个文本框,如果按照命名约定进行的话
标签: vb.net windows visual-studio-2010 isnumeric