I need some help with visual basic code, I need to create a timer that will be visible while playing a game, i know there is a timer in the tools that you pull over to the project and is hidden, and then i create a label on the page itself, the purpose is to show in seconds how long it takes to complete a game. what is the code that will link the timer with label so when i start my game you can see how many seconds it is taking.
2 4837
I need some help with visual basic code, I need to create a timer that will be visible while playing a game, i know there is a timer in the tools that you pull over to the project and is hidden, and then i create a label on the page itself, the purpose is to show in seconds how long it takes to complete a game. what is the code that will link the timer with label so when i start my game you can see how many seconds it is taking.
(Note, I'm assuming VB6 here...)
One simple way would to store the value returned by the Timer() function (ignore the name, it's just a coincidence) when you start, then in the Timer1_Timer event, set the label caption to the difference between that original value and the current time.
For example, create a new form, add a timer (with Interval = 1000) and a label, and paste this into the code window... - Option Explicit
-
DefLng A-Z
-
-
Private StartTime As Long
-
-
Private Sub Form_Load()
-
StartTime = Timer
-
End Sub
-
-
Private Sub Timer1_Timer()
-
Label1.Caption = CLng(Timer - StartTime)
-
End Sub
Hi, see if this helps at all...
Display Time - Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
-
TimeToolStripMenuItem.Text = Now.ToLongTimeString() 'Display time in menu strip
-
End Sub
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Eli |
last post by:
I'm developing a Visual Basic .Net app that interacts with
Visio 2002. I have an event handler in VB to handle the
Visio "SelectionChanged" event. This event handler is
called when the event is fired. However, the handler
quits when it tries to enable my timer.
Private Sub oVisioApp_SelectionChanged(ByVal Window As
Microsoft.Office.Interop.Visio.Window) Handles
oVisioApp.SelectionChanged
|
by: rgb |
last post by:
I've got Visual Studio 6.0 and I'm working on a Visual Basic applicaiton.
There a couple parts that really require C.
I've done C programming on a mainframe but nothing on a PC.
So I'm trying to find an example of how to write a function that
has object visibility in VB.
The functionality I want to implement is quite straightforward.
VB will pass me 2 huge byte arrays and about 10 numerical values
that 'tell me how to proceed'. I'll...
|
by: john |
last post by:
I searched http://www.sellsbrothers.com. and could not find anything
about this subject.
How do I make C# User Controls Visible to Visual Basic 6.0
Applications?
Thanks,
John
|
by: smeagol |
last post by:
Hi, is possible to create an OCX with .NET?
I need to use a control (user control) in Visual Fox Pro, but the old fox
doesn't accept usercontrols.
Any help are welcome
|
by: DaWoE |
last post by:
Hi all,
I'm fairly new to ASP.NET. What i want to do is creat a online
registration form. On the first step is getting the users details and
the number of people he wants to register.
Based on the number of people i want to create a form where he can enter
the persons details.
For example he wants to register 3 people. Then the second step of the
registration would have to be like this :
| |
by: Nathan Sokalski |
last post by:
I am trying to learn how to use the System.Timers.Timer control to perform
an action every certain amount of time. However, the Elapsed event doesn't
want to fire, but I can't figure out why. I looked at several code examples
online, but I think I was doing everything the same way they were. Does
anybody have a complete example in VB.NET (the whole aspx and aspx.vb file
so I know I am including everything) that I can look at? Any help would...
|
by: zurg |
last post by:
As far as I remember somewhere here was posted a question about Timer that
was stoping at midnight(0.00 a.m.). I'm going to face this problem tommorow
(implemeting a long working timer) so if anyone remember the solvation I
would be very greatful...
|
by: dgardner |
last post by:
This one has me stumped and I hope someone can help.
I have a form with a button on it. When I click the button, I want a
label named lblWait to be visible. (When the form opens, the label is
not visible.)
I have this line of code:
Me.lblWait.Visible = True
Then there is a line that defines strSQL. This takes a minute or so.
|
by: =?Utf-8?B?U2Vhbk1hYw==?= |
last post by:
I am familiar with how to use winsock in vb6 to create a network app. I'm
trying to find a way to take the current vb6 app and create a windows service
using system.net.sockets. How do you create a service (for the server side)
that accepts incoming client connections using system.net.sockets?
--
Sean McIntire
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |