|
Hi,
Try to override the WndProc method:
Protected Overrides Sub WndProc(ByRef m As Message)
If m.Msg = &H4a Then
Else
MyBase.WndProc(m)
End If
End Sub
Hope this helps.
The quick red ProgramFOX jumps right over the Lazy<Dog> .
|
|
|
|
|
Yes, when I try something like this I get an error:
Error 2 'WndProc' is not a member of 'System.Windows.Forms.Form'. C:\Program Files\Measurement Computing\DAQFlex for Windows CE\Examples\VB\AOut\AOutForm.Common.vb 18 13 AOut
What to do?
|
|
|
|
|
I think you get the error because you use Windows CE. Have a look at this WndProc method for Windows CE:
MessageWindow.WndProc Method[^]
Hope this helps.
The quick red ProgramFOX jumps right over the Lazy<Dog> .
|
|
|
|
|
It does not work, because my class is inherited form System.Windows.Forms.Form. The class cannot recognize WndProc.
|
|
|
|
|
|
I am doing a project, the VB program running in PC, reading data from a device, I use a timer control to read the data, in 200 ms interval.
Then I need to store the data to a text file, each set of data with a timestamp, which be used to check when the data be acuqired.
Now I use DateTime.Now property as timestamp, but I found the interval between two timestamp is not equal to 200ms, it's much bigger than 200ms, about 500-700ms.
I wonder if the Now property is not precise, or the VB program consume some time to do other things, then the VB program is not able to handle the reading task on time requirement.
modified 11-Apr-13 16:05pm.
|
|
|
|
|
Your program isnt the only one running, so you cant know when exactly youll get the thread proccessed. And the time could vary from comuter to computer, however you can give it a higher priority, but than you'll get other problems...
The easiest thing is to get the time stamp from the physical device, if it is that important.
modified 11-Apr-13 15:46pm.
|
|
|
|
|
Thanks, you reminded me how the OS do it's work.
Then the DateTime.Now property, in fact, can't get precise timer stamp, right? since it depends on the thread calling it, and OS.
|
|
|
|
|
You get the time when it is being proccessed if that matters, the trouble is you dont know exactly when youll get it.
|
|
|
|
|
econy wrote: I wonder if the Now property is not precise
There's TickCount[^], and there's Ticks[^]. You want the latter.
Do take in account that you're not guaranteed to get CPU-time every 200ms. If it must react to each event of the device, the best path would be to write a device-driver. That would take you beyond VB though.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
|
You're welcome
|
|
|
|
|
Since Windows is not a "real-time" operating system, it's impossible to get a precise 200ms tick on any timer.
|
|
|
|
|
On most computers the minimum increment of the DateTime.Now property is 15.625ms, so on average your timestamps will be accurate to about half of that. A 200ms timer won't fire at exactly 200ms (probably 190-210) but your observation of a consistently prolonged interval is indicative of a delayed timer event. The most likely reason for this is that the time taken to read the device and process the data is actually 500-700ms.
To find out what's going on, a bit more data needs to be gathered within your timer event handler.
PSEUDOCODE
==========
OnTimerTick()
ts1 = GetTimeStamp
ReadDevice
ts2 = GetTimeStamp
ProcessData
ts3 = GetTimeStamp
and then calculate
readingTime = ts2 - ts1
processingTime = ts3 - ts2
You can use the System.Diagnostics.Stopwatch class to get microsecond accurate timestamps.
Alan.
|
|
|
|
|
Read MSDN example:
Imports System
Imports System.Diagnostics
Imports System.Threading
Class Program
Shared Sub Main(ByVal args() As String)
Dim stopWatch As New Stopwatch()
stopWatch.Start()
Thread.Sleep(10000)
stopWatch.Stop()
Dim ts As TimeSpan = stopWatch.Elapsed
Dim elapsedTime As String = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10)
Console.WriteLine( "RunTime " + elapsedTime)
End Sub
End Class
Then I try to create a new console project to test the example, when I build it, I got an error message: SubMain was not found in "testStopWatch.Module1".
According to the example, it should be a console project, but dont know why VSTUDIO need a module.
modified 11-Apr-13 15:34pm.
|
|
|
|
|
I think is should read
Module Program
anmd not
Class PRogram
|
|
|
|
|
If you open the projects' properties, you'll find that they entry-point is "Module1". Change that, or change the code to using a module;
Namespace testStopWatch
Public Module1
Shared Sub Main(ByVal args() As String)
End Sub
End Module
End Namesapce
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I dont get that when I open a new project in VB console:
Module Module1
Sub Main()
End Sub
End Module
Why the sheard sub main?
|
|
|
|
|
You're absolutely right, it shouldn't be "shared" when in a module, only when in a class. My bad
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Ah, I though I had missed a lesson there
|
|
|
|
|
Kenneth Haugland wrote: Ah, I though I had missed a lesson there Noes, I'm just bad at remembering those lessons. And, there's no compiler-warnings when editing code in a post
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Just figured out, from my previous posts, that it dosnt spell check either.
|
|
|
|
|
..hehe, I used Google Translate on "sheard" and realized it had to be "shared" when typing
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
|
Does VB.Net has a timer function, I want to use a timer like:
timer.start();
do sth1
timer.now() in milliseonds
do sth2
timer.now() in milliseconds
d0 sth3
timer.now() in milliseconds.
Now I use Now() function, but I felt this function can't produce precise result.
And I googled stopwatch class, but it needs start(), stop() repeatedly.
modified 11-Apr-13 14:27pm.
|
|
|
|