VBA记录当前系统时间并精确到毫秒
想做个功能,点一次按钮,就在A1记录一次当前系统时间,要精确到毫秒的。再点一次按钮就在A2显示,以此类推!
例如:这个功能可以用来做歌词记时间!
Sub ttt()
ActiveCell.Select
tt = Timer
h = Int(tt / )
m = Int((tt - * h) / )
s = Int(tt - h * - m * )
ss = Left(tt - Int(tt), )
Selection.NumberFormatLocal = "yyyy-mm-dd hh:mm:ss.000"
Selection.Value = h & ":" & m & ":" & s & ss
ActiveCell.Offset(, ).Select
End Sub
上面的代码确实可以实现这个功能,可是还有个问题,当超过一个屏幕的时候,点着点着,按钮点不到了,excel视图随着点击按钮新的内容屏幕往下移了,按钮看不到了,你不能改变光标位置。所以我再次改良如下代码:
Sub testTime()
Dim tt, n
tt = Timer
n = Range("A65536").End(xlUp).Row
h = Int(tt / )
m = Int((tt - * h) / )
s = Int(tt - h * - m * )
ss = Left(tt - Int(tt), )
Cells(n + , ).NumberFormatLocal = "hh:mm:ss.000"
Cells(n + , ) = h & ":" & m & ":" & s & ss
End Sub
这个方法可以完美的记录歌词的时间了。
参考出处:http://www.excelpx.com/thread-329989-1-1.html
VBA记录当前系统时间并精确到毫秒的更多相关文章
- 【Java】得到当前系统时间,精确到毫秒
import java.text.SimpleDateFormat; import java.util.Date; import java.util.Calendar; public class Ma ...
- Java得到当前系统时间,精确到毫秒的几种方法
import java.text.SimpleDateFormat; import java.util.Date; import java.util.Calendar; public class Ma ...
- PHP时间戳与时间相互转换(精确到毫秒)
原文:PHP时间戳与时间相互转换(精确到毫秒) /** 获取当前时间戳,精确到毫秒 */ function microtime_float(){ list($usec, $sec) = explo ...
- oracle获得当前时间,精确到毫秒并指定精确位数
oracle获得当前时间的,精确到毫秒 可以指定精确豪秒的位数 select to_char(systimestamp, 'yyyymmdd hh24:mi:ss.ff ') from dual; ...
- gettimeofday() 获取系统时间,精确到微秒 这个似乎只能在linux 下用,不能在windows 下用
struct timeval{ long int tv_sec; // 秒数 同time(NULL) 的返回值 long int tv_usec; // 微秒数 10 的6次方 }; struct t ...
- Linux获取系统当前时间(精确到毫秒)
#include <stdio.h> #include <time.h> #include <sys/time.h> void sysLocalTime() { t ...
- 怎么使用Delphi获取当前的时间,精确到毫秒
先介绍一个可能比较常用的方法,获取当前时间 var datetime: string; begin datetime:= FormatDateTime('yyyy-mm-dd hh:mm:ss', N ...
- C/C++ 获取系统时间 到秒 || 到毫秒
string getNowSysTime(string &outPut) { ] = {}; struct timeval tv; struct timezone tz; struct tm ...
- mysql 时间类型精确到毫秒、微秒及其处理
一.MySQL 获得毫秒.微秒及对毫秒.微秒的处理 MySQL 较新的版本中(MySQL 6.0.5),也还没有产生微秒的函数,now() 只能精确到秒. MySQL 中也没有存储带有毫秒.微秒的日期 ...
随机推荐
- Dajngo admin使用
Dajngo admin使用 Django 提供了基于 web 的管理工具. Django 自动管理工具是 django.contrib 的一部分.你可以在项目的 settings.py 中的 INS ...
- 我的Android进阶之旅------> Android为TextView组件中显示的文本添加背景色
通过上一篇文章 我的Android进阶之旅------> Android在TextView中显示图片方法 (地址:http://blog.csdn.net/ouyang_peng/article ...
- python -virtualenvwrapper 切换不同的python版本
环境: 安装了python2.7和python3.4, 两个版本都安装了virtualenv和virtualenvwrapper 在windows cmd中键入mkvirtualenv -p C:\P ...
- 使用JavaScript定义一个微信小程序插件样例
var wxTimer = new wxTimer({ beginTime: "00:00:20", complete: function () { wx.redirectTo({ ...
- weak 的内部实现原理
问题 weak 变量在引用计数为0时,会被自动设置成 nil,这个特性是如何实现的? 答案 在 Friday QA 上,有一期专门介绍 weak 的实现原理.https://mikeash.com/p ...
- 总结:iview(基于vue.js的开源ui组件)学习的一些坑
1.要改变组件的样式 找到这个组件的class名,然后覆盖样式. 举例:修改select框,显示圆角.只需给找到类名并写样 .ivu-select-selection{ border-radius:1 ...
- 【二叉堆】k路归并问题(BSOJ1941)
Description 有n个函数,分别为F1,F2,...,Fn.定义Fi(x)=Ai*x^2+Bi*x+Ci(x∈N*).给定这些Ai.Bi和Ci,请求出所有函数的所有函数值中最小的m个(如有重复 ...
- hd acm1061
Problem Description Given a positive integer N, you should output the most right digit of N^N. Inp ...
- curl 监控web
[root@rhel6 ~]# curl -I -s -w "%{http_code}\n" -o /dev/null http://127.0.0.1 [root@rhel6 ~ ...
- Spring Cloud之Hystrix服务保护框架
服务保护利器 微服务高可用技术 大型复杂的分布式系统中,高可用相关的技术架构非常重要. 高可用架构非常重要的一个环节,就是如何将分布式系统中的各个服务打造成高可用的服务,从而足以应对分布式系统环境中的 ...