是否可以或者我需要先转换它?这是我的代码,但输出错误:
TextBox7.Text = TextBox6.Text + time.Text.Substring(4)
这将是样本运行:
TextBox6.Text = "5.12"
time.Text = "9.51 AM 3/3/2014"
结果如下:
Textbox7.Text = "14.63 AM 3/3/2014"
预期结果:
Textbox7.Text = "15.03 AM 3/3/2014"
答案 0 :(得分:0)
尝试像这样
TextBox7.Text = Val(TextBox6.Text) + Val(Strings.Left(time.Text.Trim,4)) &
Val(Strings.Right(time.Text.Trim,(time.Text.Trim.Length-4)))
修改强>
TextBox7.Text = Format(Val(TextBox6.Text) + Val(Strings.Left(time.Text.Trim, 4)),
"##.##") & Strings.Right(time.Text.Trim, 12)
编辑新要求:
TextBox3.Text = Format(Val(TextBox6.Text) + Val(Strings.Left(time.Text.Trim, 5)), "##.00")
If Val(TextBox6.Text.Trim.Split(".")(1)) >= 60 Then
TextBox6.Text = Val(TextBox6.Text.Trim.Split(".")(0)) + 1 & "." &
Val(TextBox6.Text.Trim.Split(".")(1) - 60)
End If
TextBox7.Text = Format(Val(TextBox6.Text), "##.##") & Strings.Right(time.Text.Trim, 12)
编辑新需求
TextBox7.Text = Format(Val(TextBox6.Text) + Val(Strings.Left(time.Text.Trim, 5)),
"#0.00")
Dim xDate As Date = Format(CDate(Strings.Right(time.Text.Trim, 12)), "tt
MM/dd/yyyy")
If Val(TextBox7.Text.Trim.Split(".")(1)) >= 60 Then
TextBox7.Text = Val(TextBox7.Text.Trim.Split(".")(0)) + 1 & "." &
Val(TextBox7.Text.Trim.Split(".")(1) - 60)
End If
If Val(TextBox7.Text) > 24 Then
TextBox7.Text = Format(Val(TextBox7.Text - 24), "##.##") & " " &
DateAdd(DateInterval.Day, 1, xDate)
End If