是否有可能使用Visual Basic以小于一秒的形式获得实时信息? [英] Is it possible to get real time information in smaller pieces than a second using Visual Basic?

查看:70
本文介绍了是否有可能使用Visual Basic以小于一秒的形式获得实时信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要帮助来测量运行时Visual Basic for Excel需要的不同子程序和函数组的时间长度。就我所知,Now例程不会以5秒的步长提供信息,因为这可能是由New使用的double类型变量记录的

I need assistance to measure how long time different groups of subroutines and funcions that Visual Basic for Excel need when running. The Now routine will not, as far as I have found out, give information in steps of 5 seconds since that is what could be recorded by the double type variable used with New.

是否可以使用货币变量而不是双重类型?

Would it be possible to use a currency variable instead of the double type?

您能给出建议或建议如何解决此问题,得到一个像0.01秒的分辨率? 

Can you give an advice or suggest how to solve this problem and get a resolution like 0.01 second? 

如果我通过在一串单元格中放置一串逻辑(NANDS)来构建一个单独的计数器并在它是运行还是会影响Visual Basic的运行? 

Will it work if I build a separate counter by placing a chain of logics (NANDS) in a chain of cells and decode this value when it is running or will this influnce the running of Visual Basic? 

Per Almgren

Per Almgren

 

推荐答案

PerAlmgren,

re: 计时代码



您可以将它包装在任何子或函数周围...



'返回数字自Windows启动以来的毫秒数。

私有声明函数timeGetTime Lib" winmm.dll" ()As Long



Sub WhatsTakingYouSoLong()

  Dim Time1 As Long

  Dim Time2 As Long

  'Dim n As Long

  'Dim m As Long

  Time1 = timeGetTime



'在我的旧机器上运行需要46毫秒

  '对于n = 1至5000000

   'm = m + 1

  '下一个¥


  Time2 = timeGetTime

  MsgBox Time2 - Time1
$
结束子

PerAlmgren,
re:  timing code

You can wrap this around any sub or Function...

'Returns the number of milliseconds elasped since Windows started.
Private Declare Function timeGetTime Lib "winmm.dll" () As Long

Sub WhatsTakingYouSoLong()
  Dim Time1 As Long
  Dim Time2 As Long
  ' Dim n As Long
  ' Dim m As Long
  Time1 = timeGetTime

'This took a 46 milliseconds to run on my older machine
  'For n = 1 To 5000000
   'm = m + 1
  'Next

  Time2 = timeGetTime
  MsgBox Time2 - Time1
End Sub

'--- < br $>
Jim Cone

美国俄勒冈州波特兰市
https:// goo .gl / IUQUN2  (Dropbox)
'---
Jim Cone
Portland, Oregon USA
https://goo.gl/IUQUN2 (Dropbox)


这篇关于是否有可能使用Visual Basic以小于一秒的形式获得实时信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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