Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Wait function and Invisible function

  Asked By: Bastet    Date: Oct 03    Category: MS Office    Views: 1121
  

For a program I'm working on I want to show an updated sheet every 0,5 second or
less.
Using below code the minimum wait time is 1 second.

Application.Wait (Now + TimeValue("00:00:01"))

I tried some other code as well but no luck so far.
Does any of you know how I can reduce the wait time?

An other thing I want to do is to show a sheet but without the name of the
workbook being visible on the taskbar. Also when this particular workbook is
open it should not be possible to open other workbooks. Actualy, ones the
program is started it not obvious any more you are looking at an Excel-sheet. I
have seen a working example of this but the code behind it is not accesable.

Can any one get me started on this?

Share: 

 

4 Answers Found

 
Answer #1    Answered By: Aaleyah Khan     Answered On: Oct 03

I use this procedure to compare timings.

The important bits for youo are the call to GetTickCount and the line
calculating milliseconds.


Option Explicit
Declare Function GetTickCount Lib "kernel32" () As Long


Public Sub subCompareSpeed()
' Compare the speed of two procs.
' The overhead of the calls should not matter because
' this is a compare and not trying to measure absolutes.

' Add whatever but leave em here

Dim lnglCounter As Long
Dim lnglMax As Long
Dim lnglTime1 As Long
Dim lnglTime2 As Long
Dim lnglTime3 As Long
Dim strlLineA As String
Dim strlLine As String
Dim strlFirstItemsList As String
Dim blnFound As Boolean

lnglMax = 1000

MsgBox strlLineA
lnglCounter = 0
strlLine = strlLineA
lnglTime1 = GetTickCount()
Do
' subStripTextChrs strlLine
lnglCounter = lnglCounter + 1
Loop Until lnglCounter >= lnglMax
lnglTime2 = GetTickCount() - lnglTime1
MsgBox "Instr took " & lnglTime2 & " ms to finish'"
MsgBox strlLine
lnglCounter = 0
strlLine = strlLineA
lnglTime1 = GetTickCount()
Do
' subStripText strlLine
lnglCounter = lnglCounter + 1
Loop Until lnglCounter >= lnglMax
lnglTime2 = GetTickCount() - lnglTime1
MsgBox "Chrs took " & lnglTime2 & " ms to finish'"
MsgBox strlLine
MsgBox "Done"

End Sub

 
Answer #2    Answered By: Marta Kim     Answered On: Oct 03

Am I right in guessing that GetTickCount is a function  thus?

Function GetTickCount()
GetTickCount = Timer
End Function

 
Answer #3    Answered By: Shaun Thomas     Answered On: Oct 03

GetTickCount is a function  in the kernel32 Library. If you declare it as
shown you should be able to use it.

 
Answer #4    Answered By: Akins Massri     Answered On: Oct 03

Out of interest here is a function  I played with to return as unique a
filename as I could work out. It worked but the name was sooooo long...

Function fncNumericDateTimeStamp(Optional spFormatString As Variant) _
As String
' Create DateTimeStamp.
' The FORMAT string may be passed.
' The Timer value and TIck count are always appended.
' The default returns a 27 character long string.

Dim slDTStamp As String
Dim llFTimer As Long
Dim llTimer As Long
Dim llITimer As Long
Dim slitimer As String
Dim slFTimer As String
Dim slTCount As String
Dim slFormatString

If IsMissing(spFormatString) Then
slFormatString = "yyyymmddhhnnss"
Else
slFormatString = spFormatString
End If

slTCount = CStr(GetTickCount())
llTimer = Timer()
llITimer = Int(llTimer)
slitimer = CStr(llITimer)
llFTimer = llTimer - llITimer
slFTimer = Mid(CStr(llFTimer), 2)
slDTStamp = Format(Now(), slFormatString)
slDTStamp = slDTStamp & slitimer & slFTimer & slTCount

' This loop ensures a different value
' from the last execution.
If slDTStamp = sgFileDateTimeStamp Then
For llTimer = 1 To 10000000
Next llTimer
slTCount = CStr(GetTickCount())
llTimer = Timer()
llITimer = Int(llTimer)
slitimer = CStr(llITimer)
llFTimer = llTimer - llITimer
slFTimer = Mid(CStr(llFTimer), 2)
slDTStamp = Format(Now(), slFormatString)
slDTStamp = slDTStamp & slitimer & slFTimer & slTCount
End If
sgFileDateTimeStamp = slDTStamp
fncNumericDateTimeStamp = slDTStamp

End Function

 
Didn't find what you were looking for? Find more on Wait function and Invisible function Or get search suggestion and latest updates.




Tagged: