
正文
vb.net时间格式毫秒的简单介绍
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
如何在vb.net中取得两时间的毫秒差
dim a1 as timespan = dtEndTime -dtStartTime
dim a2 as integer = a1.TotalMilliseconds
相关问答
Q1: vb.net如何获取时间格式?
可以访问注册表HKEY_CURRENT_USER\Control Panel\International下面vb.net时间格式毫秒的一些键值
如sShortDate键值表示vb.net时间格式毫秒的是短日期sLongDate表示vb.net时间格式毫秒的是长日期
中文下vb.net时间格式毫秒的短日期是 yyyy-M-d
中文下vb.net时间格式毫秒的长日期是 yyyy'年'M'月'd'日'
Q2: 用VB.NET设计一个以秒为基本单位的表,并且显示在窗体上的步骤,并且给出关键代码
是我以前自己设计的用来测试自己点钞速度用的,希望是你需要的
以下是窗体的全部代码
Public Class Form1
Dim StartFlag As Boolean = False
Dim secon As Integer
Dim minut As Integer
'空格
Private Sub Form1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp
If e.KeyCode = Keys.Space Then
If StartFlag Then
StartFlag = False
Timer1.Enabled = False
If Val(Strings.Right(Label1.Text, 2)) 10 And Val(Strings.Right(Label1.Text, 2)) = 0 Then secon = 0 : minut = 0 : Label1.Text = "00:00" : Exit Sub
ListBox1.Items.Add(Label1.Text.ToString)
ListBox1.SelectedItem = ListBox1.Items.Count - 1
Label1.Focus()
Button1.Enabled = True
Label1.Text = "00:00"
secon = 0
minut = 0
Else
StartFlag = True
Timer1.Enabled = True
End If
End If
End Sub
'加载
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ListBox1.Items.Clear()
Label1.Text = "00:00"
Button1.Enabled = False
secon = 0
minut = 0
Label1.Focus()
End Sub
'清空
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Button1.Enabled = False
ListBox1.Items.Clear()
Label1.Focus()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
secon += 1
If secon = 60 Then
secon = 0
minut += 1
End If
Dim seconStr As String = secon
If seconStr.Length = 1 Then seconStr = "0" + seconStr
Dim minutStr As String = minut
If minutStr.Length = 1 Then minutStr = "0" + minutStr
Label1.Text = minutStr + ":" + seconStr
Label1.Focus()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim SeconSun As Integer
If ListBox1.Items.Count 0 Then
For i = 0 To ListBox1.Items.Count - 1
Dim TemStr As String = ListBox1.Items.Item(i).ToString
Dim TemInt1 As Integer = Val(Strings.Right(TemStr, 2))
Dim TemInt2 As Integer = Val(Strings.Left(TemStr, 2))
Debug.Print(TemInt1.ToString)
Debug.Print(TemInt2.ToString)
SeconSun += TemInt1 + TemInt2 * 60
Debug.Print(SeconSun.ToString)
Next
TextBox1.Text = (SeconSun / ListBox1.Items.Count).ToString + "秒"
End If
Label1.Focus()
End Sub
End Class
Q3: VB.NET 计时器的问题
不对。步骤如下:
添加一个label标签名字label1 用来显示时间
再添加一个timer控件 名字timer1 interval属性=1000 用来计时
窗体添加代码
Dim t As Date '用来记录时间
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles Timer1.Tick
t = t.AddSeconds(1)
Label1.Text = "登录时间:" t.TimeOfDay.ToString
End Sub
Q4: VB 中如何表示系统时间 能精确到毫秒吗
试过NN次后,我“也”发现这种记录时间的精度为10.0144毫秒,
看来,这个问题是由CLR决定的,如果,只使用FCL的函数,看来没办法解决这一问题了!
看了 LoveCherry(论成败,人生豪迈;大不了,重头再来!^_^) ,给出的文章链接,
受了些启发,对于文章中实现的那个A类,我没看太明白,但是,文章中用到了QueryPerformanceCounterp这个win API函数,楼主,可以导入用一下,我试过多次,在我的机子上,其精度为 210/1000 毫秒左右。
QueryPerformanceCounter这个函数的是一个计数器函数,以百万分之一秒为单位,来记算时间数。
//=============
using System.Runtime.InteropServices;
using System.Threading;
[DllImport("kernel32.dll")]
static extern bool QueryPerformanceCounter([In, Out] ref long lpPerformanceCount);
long t1 = 0;
long t2 = 0;
QueryPerformanceCounter(ref t1);
Thread.Sleep(1); //挂起一毫秒,作为演示
QueryPerformanceCounter(ref t2);
long sp = t2 - t1;//sp的单位为百万分之一秒
float f_time = (float)((decimal) sec / (decimal)10000); //得到0.0001毫秒的精度
f_time = float.Parse(string.Format("{0:F1}",f_time)); //f_time是经过四舍五入,得到的0.1毫秒的精度
Q5: VB.NET用TIMER控件
vb.net时间格式毫秒我使用Visual Basic 2008 编写
1、新建2个窗体Form1和Form2
2、Form1窗体新建一个Button按扭和一个Timer1控件
3、打开Form1编写如下代码
Public Class Form1
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Form2.Show()
Me.Hide() '隐藏本窗体
Timer1.Enabled = False '使其只执行1次
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Enabled = True '能使用 其实这个在属性窗口中更容易设置
Timer1.Interval = 2000 '毫秒 即2秒
End Sub
End Class
关于vb.net时间格式毫秒和的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。





