如何在Vb.net中区分两个DropdownList值 [英] How to differenciate of Two DropdownList values in Vb.net
问题描述
大家好,我遇到了两个DropDownList值不同的问题.我是手动输入两个DropDownList的值.
值是时间,如
01:00
01:30
02:00
-----
-----
23:59
并且与第二个DropdownList相同.
我想两者都不同.我将在差异的texbox中显示.
例如:我需要的是dropdown2-dropdown1 = 02:00-01:00 = 00:30.
怎么做.
请任何人帮帮我.
Hi Guys , I have facing the problem of differenciate of two DropDownList values. I was enter the values manually of both DropDownList.
The values are Time like
01:00
01:30
02:00
-----
-----
23:59
and also same as second DropdownList.
I want to difference of both. I will display in texbox of difference.
For example : differenciate from dropdown2 - dropdown1= 02:00 - 01:00 = 00:30 that is i want.
How to do this.
Please any one help me.
推荐答案
这是一个示例,
here is an example,
Dim t1 As TimeSpan
Dim dt2 As DateTime = Convert.ToDateTime("01/01/2001 02:00")
Dim dt1 As DateTime = Convert.ToDateTime("01/01/2001 01:30")
t1 = dt2.Subtract(dt1)
Dim duration = t1.Hours.ToString("00") & ":" & t1.Minutes.ToString("00")
'02:00 - 01:30 = 00:30
'replace underline time value with dropdownlist.text
'eg. Convert.ToDateTime("01/01/2001 " & dropdown2.text)
祝您编码愉快!
:)
Happy Coding!
:)
首先获取下拉列表的值.现在它们是字符串格式,因此转换为DateTime然后减去.
First get the value of dropdownlists. Now those are in string format, so convert into DateTime then subtract.
这篇关于如何在Vb.net中区分两个DropdownList值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!