从datetimepicker显示小时和分钟 [英] displaying hours and minutes from datetimepicker

查看:104
本文介绍了从datetimepicker显示小时和分钟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这里,我已经通过比较两个datetimepickers的值来显示状态,如何通过比较datetimepicker中显示的时间来显示小时.



here i had displayed the status by comparing the values of two datetimepickers , how can i display the hours by comparing the time displayed in the datetimepicker.



Dim d1 As DateTime = Me.DateTimePicker2.Value
        Dim d2 As DateTime = Me.DateTimePicker3.Value
        If d2 <= d1 Then
            TextBox12.Text = " ON-TIME"
        ElseIf d2 > d1 Then
            TextBox12.Text = " DELAY"
        End If

推荐答案

使用System.DateTime.ToString(string)和适当的格式字符串.参见:
http://msdn.microsoft.com/en-us/library/zdtaw1bw.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/az4se3k1.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx [ ^ ].

—SA
Use System.DateTime.ToString(string) with appropriate format string. See:
http://msdn.microsoft.com/en-us/library/zdtaw1bw.aspx[^],
http://msdn.microsoft.com/en-us/library/az4se3k1.aspx[^],
http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx[^].

—SA


要从DateTimePicker值获取小时,请使用以下代码:
To get Hour from the DateTimePicker Value use the following code :
Dim _hour As Int32 = DateTimePicker1.Value.Hour


使用以下代码:


Use the following code :

Dim d1 As Int32 = Me.DateTimePicker1.Value.Hour
Dim d2 As Int32 = Me.DateTimePicker2.Value.Hour
If d2 <= d1 Then
    TextBox12.Text = " ON-TIME"
ElseIf d2 > d1 Then
    TextBox12.Text = " DELAY" & (d2 - d1) & "Hours"
End If


希望对您有帮助. :)


I hope it will help you. :)


这篇关于从datetimepicker显示小时和分钟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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