我有一次这样的可变性:
dim startime as timespan
我的开始时间值是:11:30:15(我的意思是11Hr.30mnt,15秒)。
我如何将每个值提取到不同的变量。我的意思是
dim hr as integer
dim mnt as integer
dim sec as integer
我想得到hr = 11,mnt = 30,sec = 15
我尝试过这样的事情:
Dim hour As integer = TimeSpan.FromHours(starttime)
但这次显示错误:
值类型'System.timespan'无法转换为'Double'
答案 0 :(得分:2)
Dim startTime As New TimeSpan(11, 30, 15)
Dim hours As Integer = startTime.Hours
Dim mnt as Integer = startTime.Minutes
Dim sec as Integer = startTime.Seconds
Dim allMinutes as Double = startTime.TotalMinutes