|
Ok, Thank you
Regards,
Chatura Dilan
|
|
|
|
|
Following is from help file in my VB.net(2001):
ReadOnly Public Property Timer() As Double
Remarks
The Timer property returns both the seconds and the milliseconds since midnight. The seconds are in the integral part of the return value, and the milliseconds are in the fractional part.
Example
This example uses the Timer function to pause the application. It can perform other processing during the pause.
Dim Start, Finish, TotalTime As Double
If (MsgBox("Press Yes to pause for 5 seconds", MsgBoxStyle.YesNo)) = _
MsgBoxResult.Yes Then
Start = Timer ' Set start time (seconds).
Finish = Start + 5.0 ' Set end time for 5-second duration.
Do While Timer < Finish
' Do other processing while waiting for 5 seconds to elapse.
Loop
TotalTime = Timer - Start ' Calculate total time.
MsgBox "Paused for " & TotalTime & " seconds"
Else
End
End If
I cannot make it work in ay way.Timer always gets underlined and I get following message:
"Timer is a type and cannot be used for expression."
How does one get it work?
I will appreciate any help you can give me with this.
Thank you Jirka
|
|
|
|
|
I think you are looking at the help for an object which has a Timer() property rather than the System.Timers.Timer object. This is the one you need. For example:
Dim myTimer As New System.Timers.Timer
myTimer.Interval = 1000
myTimer.Enabled = True
myTimer.Start()
Don't forget to establish the event handlers for myTimer.
...Steve
1. quod erat demonstrandum
2. "Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." I read that somewhere once
|
|
|
|
|
Hi, thank you for your answer, but this is not what I was looking for. Ordinary timers and even "server timer" are not exact enough for my purpose.
I was running two of them one interval exactly 45 times of the other and usually faster one got only 35 ticks before slower one ticked.
Since my post I found this:
"System.Environment.TickCount "
which seems to work similar to the thing from my first post. It shows ticks every milisecond but not since midnigt, because at 4PM count was only about 8 000 000 since midnight it should have been 57 000 000.
Does anybody know when the count starts and when it resets if ever?
My VB.Help does not mention it at all.
Thank you Jirka
|
|
|
|
|
Jirikub wrote: System.Environment.TickCount
This is not the tick count since midnight. It's the tick count since the system was started, and if left running, will rollover Int32.MaxValue to Int32.MinValue in just short of 25 days. The resolution is about 500 milliseconds. One tick is about 100-nanoseconds.
The timer you use depends on the application requirements. Different timers use differents methods to signal your app that they have elapsed. Forms-based timers use events, which don't fire exactly on time and there can also be a delay in your code getting the event if your app's message queue gets bogged down with many events. Other timers use callbacks to call your code directly on a seperate thread.
Soooo, what are you trying to do with these timers?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thank you for your information, it should help. I am trying to make sort of metronom to assist with exercise and there will be graphics synchronized to exercise, but mostly goal is to learn VB. I must add that in this VB-Help is most unhelpful, if it was not for people like you and others, who are willing to spend time helping us dummies I would probably give up. Ilearned a lot just by reading these forums.
Thank you Jirka
|
|
|
|
|
Jirikub wrote: I am trying to make sort of metronom to assist with exercise and there will be graphics synchronized to exercise
OK. Should be easy enough.
But why two timers?? Why not just one?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Dave Kreskowiak wrote: But why two timers?? Why not just one?
One timer is set by user choosing speed of exercise, range 10-25 moves a minute. Faster one is set 45 times faster to sequence graphic display. When I tried using one timer and just add it 45 times total time varied wildly, setting of 18 mpm could get you 14 or 15 instead. Time was affected by loading graphics and sounds which are part of the program. Of course with two timers exercise speed would be close to that set, but graphics would finish too early or not finish at all. I also suspect that it would change on different machines. I write this on 3GHz computer,but it will run on old 1GHz in basement. Now that I do not use timers at all, just check everything against this "System.Environment.TickCount" it works fine.
Jirka
|
|
|
|
|
Hi,
How to we play music files (e.g .wma or .mp3 etc) in a vb.net application when the application is running?
And how to let a few songs play one after the other? i.e when the first song finishes, the second one starts after a short pause.
|
|
|
|
|
|
Can someone please explain to me the logic and theory of why we need to use Table adapters. I know they are important in terms accessing your data from your database (access database is what im using because our computers do not have SQL on them at uni)and putting it into a dataGrid on a windows application, but i still have no concept on how to do that as our tutors didnt go over then in details.
for example my Code: it will not run past since i hve not declaired CheckUserAdapter and CheckUserTable, but im not sure how to.
Public Function UserPasswordMatches(ByVal userName As String, ByVal password As String) As Boolean
CheckUserAdapter.Fill(CheckUserTable)
Dim CheckUserDataView As DataView = CheckUserTable.DefaultView
CheckUserDataView.RowFilter = "Name = '" + userName + "'"
With CheckUserDataView
If .Count > 0 Then
Dim SecretKey As String = "785&*(%HUYFteu27^5452ewe"
If .Item(0).Item("Password").ToString.Trim <> vbNullString Then
Dim EncryptedPassword As String = Encryptstring(password, SecretKey)
If .Item(0).Item("Password").ToString.Trim = EncryptedPassword Then
Return True
Else
Return False
End If
Else
If password = vbNullString Then
Return True
End If
End If
Else
Return False
End If
End With
End Function
Thankyou
|
|
|
|
|
Can i call java code from vb.net , is there any way to do it ?
|
|
|
|
|
Not directly.
You have to use something in common that the two runtimes can use to communicate through. In this case, I believe that's COM. Depending on which codebase you want to use as a server, that code would have to expose some kind of COM interface (wrapper) so the other runtime can call it. In VB.NET, this is relatively easy. In Java, I have no idea what's involved, or if it's even possible. But, the client would just instantiate the server just like any other COM-based component.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I think Java does CORBA and not COM.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Well, You can either use J#. Or, use IKVM to call the Java Code. But, don't expect it to be fast, since you're running a VM on a VM....
Yuvi Panda T
Microsoft Student Partner
Blogs at : http://yuvipanda.blogspot.com
|
|
|
|
|
i think i will try to use IKVM cause my code is not big so it will run with normal speed
thanks all
|
|
|
|
|
Hello!
The subject is not directly related to vb.net. However, I got the best answers from this forum so I decided to ask you.
My asp page shows pictures of the estates in the page. What I want is to put a transparent water mark on the pictures automatically if they have been rented or sold. How can I do that without developing an application to do it?
Can I put one transparent picture above another one in the same cell of the table?
Thanks
|
|
|
|
|
B Journey wrote: My asp page shows pictures of the estates in the page. What I want is to put a transparent water mark on the pictures automatically if they have been rented or sold. How can I do that without developing an application to do it?
You can't. You'll be writing an ISAPI extension to handle the JPG extension to add the watermark. You can find an example here[^].
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
How can I convert a VB6 project to VB.Net
... Most people can speak several languages but I speak only one; that's 01010110 ...
|
|
|
|
|
All you have to do is open the VB6 .VBP file from the File/Open menu. This will automatically launch the Visual Basic Upgrade Wizard to try and convert the project.
Be warned though! This will NOT convert every project to VB.NET and the code that code convert is not necessarily the best way to do things in VB.NET, nor is it the best performing code. Also, if you plan to alter the code in the converted app, be prepared to have a hard time getting questions answered. The VBU Wizard can generate code that's difficult to follow, let alone debug.
The BEST solution for upgrading a VB6 app to .NET is to scrap it and rewrite it from scratch!
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
i am using richtextbox for input mathematical equations & formule. how can i access(place) ms eqaution editor in ritchtextbox? how can i access windows/ ms word toolbar in my application without open document?
-- modified at 1:00 Monday 24th April, 2006
|
|
|
|
|
IN A PROJECT, i extended picturebox class, then added a context menu to picture box.
in a form , i used picturebox, how to add new contextmenuitems to picture box?
|
|
|
|
|
The extact same way...
Create a ContextMenuStrip object and fill in the stuff you want, then go into the properties of the PictureBox control and change its ContextMenuStrip property to the name of your menu.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
In my project i have to show a form using a string variable, that means
the form name is available in a string variable like,
strFormToShow = "Form2" and form2 is available in my project. How can i
show this form2 using this string variable ?
pls help me, urgent
regards
ajo
|
|
|
|
|
First rethink your pbolem. Is this really the way you would like to open forms? I smell a bad design
But anways, look at Reflection, that should be the solution for your problem.
--------------------------------------------------------
My development blog
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|