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
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
Dim i As Integer
Integer.TryParse(value, i)
Console.WriteLine("Integer:", i)
也许这样的事情会起作用:
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
要将包含数值的字符串转换为实际的数值类型(例如 int),您需要使用
Integer.Parse(someString)