-3

i am getting error in 1st line

Dim result = (CInt(Split(Overtime.Text, ":")(0)) * 60 + CInt(Split(Overtime.Text, ":")(1)))
OvertimeAmount.Text = (result * Val(OvertimeRate.Text)) / 60
4

3 回答 3

3
Dim i As Integer
Integer.TryParse(value, i)
Console.WriteLine("Integer:", i)
于 2013-05-20T18:00:18.703 回答
0

也许这样的事情会起作用:

Dim Result as Integer = TimeSpan.Parse(Overtime.Text).TotalMinutes
OvertimeAmount.Text = ((result * Val(OvertimeRate.Text)) / 60).ToString

这假设您正在验证超时中的文本。如果没有,您可以使用 TryParse 方法。

    Dim ts As New TimeSpan
    Dim ValidText As Boolean = TimeSpan.TryParse(Overtime.Text, ts)
    If ValidText Then
        Dim Result as Integer = ts.TotalMinutes
    End If
于 2013-05-21T04:18:05.677 回答
0

要将包含数值的字符串转换为实际的数值类型(例如 int),您需要使用

Integer.Parse(someString)
于 2013-05-20T17:57:29.517 回答