如何将Timespan转换为整数? [英] How Do I Convert Timespan To Integer?

查看:279
本文介绍了如何将Timespan转换为整数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在写一个简单的停车场项目。我需要做的是输入到达时间和离开时间,然后应用程序应根据汽车在停车场停留的时间进行计算。



我的问题是我不知道如何将时间跨度值转换为整数值以便进行这些操作。这就是我到目前为止所做的...







公共类Form1



Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles Button1.Click



Dim final As String = TextBox4.Text

Dim inicial As String = TextBox3.Text

Dim tiempoI As TimeSpan = TimeSpan.Parse(inicial)

Dim tiempoF As TimeSpan = TimeSpan.Parse(final)

Dim resta As TimeSpan = tiempoF - tiempoI

TextBox5.Text = resta.ToString

< br $>
结束子

结束班



有什么帮助吗?

解决方案

FromTicks 会给你一个很长的值 - http://msdn.microsoft.com/en-us/library/system.timespan.fromticks%28v=vs.110%29.aspx [ ^ ]。

Hi, Im writing a simple parking lot project. What I need to do is to input a arrival time and a departing time, then the application should make calculations based on how munch time the car stayed on the parking lot.

My problem is that I don't know how to covert that timespan value to a integer value in order to make those operations. This what I done so far...



Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim final As String = TextBox4.Text
Dim inicial As String = TextBox3.Text
Dim tiempoI As TimeSpan = TimeSpan.Parse(inicial)
Dim tiempoF As TimeSpan = TimeSpan.Parse(final)
Dim resta As TimeSpan = tiempoF - tiempoI
TextBox5.Text = resta.ToString

End Sub
End Class

ANY HELP PLEASE?

解决方案

FromTicks will give you a long value - http://msdn.microsoft.com/en-us/library/system.timespan.fromticks%28v=vs.110%29.aspx[^].


这篇关于如何将Timespan转换为整数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆