Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 29th, 2004, 01:29 PM
paparika paparika is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 31 paparika User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 m 37 sec
Reputation Power: 6
the stop watch program

i've been give a program to do, my teacher has supplied me with what goes where etc..... but it seems to be a typo because i have checked and this error keeps popping up..


Private Sub cmdStart_Click()

' Store the current date/time (Now) in a variable:
StartTime = Now
' Format the stored date/time to show hours,
' minutes, and seconds, and show it in the Label:
lblStartTime.Caption = Format(StartTime, "hh:mm:ss")
' Disable the start button (we've already started)...
cmdStart.Enabled = False
'...and enable the stop button:
cmdStop.Enabled = True

End Sub


the text in colour is the error.
I wonder if anyone has any suggestions please

many thanks

Reply With Quote
  #2  
Old January 29th, 2004, 02:19 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 13th Plane (11000 - 11499 posts)
 
Join Date: Jun 2003
Posts: 11,141 Doug G User rank is Lieutenant General (80000 - 90000 Reputation Level)Doug G User rank is Lieutenant General (80000 - 90000 Reputation Level)Doug G User rank is Lieutenant General (80000 - 90000 Reputation Level)Doug G User rank is Lieutenant General (80000 - 90000 Reputation Level)Doug G User rank is Lieutenant General (80000 - 90000 Reputation Level)Doug G User rank is Lieutenant General (80000 - 90000 Reputation Level)Doug G User rank is Lieutenant General (80000 - 90000 Reputation Level)Doug G User rank is Lieutenant General (80000 - 90000 Reputation Level)Doug G User rank is Lieutenant General (80000 - 90000 Reputation Level)Doug G User rank is Lieutenant General (80000 - 90000 Reputation Level)Doug G User rank is Lieutenant General (80000 - 90000 Reputation Level)Doug G User rank is Lieutenant General (80000 - 90000 Reputation Level)Doug G User rank is Lieutenant General (80000 - 90000 Reputation Level)Doug G User rank is Lieutenant General (80000 - 90000 Reputation Level)Doug G User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 2 Days 17 h 15 m 54 sec
Reputation Power: 857
What's the error?

Reply With Quote
  #3  
Old January 29th, 2004, 02:50 PM
paparika paparika is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 31 paparika User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 m 37 sec
Reputation Power: 6
the error is claimed to me

StartTime = Now

compile error:

variable not defined

Reply With Quote
  #4  
Old January 29th, 2004, 03:32 PM
Fisherman's Avatar
Fisherman Fisherman is offline
Inherits Programmer.Slacker
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2003
Location: Between my Id and your Ego
Posts: 2,193 Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 13 h 55 m 17 sec
Reputation Power: 142
Send a message via ICQ to Fisherman Send a message via AIM to Fisherman
if you have Option Explicit turned on, then I don't see where you've declared StartTime to be a variable. Declare that variable, and I would assume that it would fix it.

Reply With Quote
  #5  
Old January 29th, 2004, 03:48 PM
paparika paparika is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 31 paparika User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 m 37 sec
Reputation Power: 6
I do have Option Explicit in the program.

Private Sub Form_Load()

' Declare three variables to hold date/time
' values.
Dim StartTime As Variant
Dim StopRime As Variant
Dim TotalTime As Variant
' Dispable the Stop button (we've not started yet):
cmdStop.Enabled = False

End Sub




this is what i have been told to enter for the decaring variants, so everything is where it should be... but this error continue to state that StartTime = Now is the problem, i cant see the error, can anyone see what i cant

Reply With Quote
  #6  
Old January 29th, 2004, 04:30 PM
Fisherman's Avatar
Fisherman Fisherman is offline
Inherits Programmer.Slacker
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2003
Location: Between my Id and your Ego
Posts: 2,193 Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 13 h 55 m 17 sec
Reputation Power: 142
Send a message via ICQ to Fisherman Send a message via AIM to Fisherman
ok.. from what I'm seeing, you're having a problem with scope. You're declaring your variable in form_load, but the variables in form load are not visible to your cmdStart_Click procedure. Unless you require the variable in form_load, cut it, and paste it into the click event for cmdStart. Remember, unless your variable is declared as either module or global - level, it will not be visible to any procedure except the one it is in.

Reply With Quote
  #7  
Old January 29th, 2004, 04:38 PM
paparika paparika is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 31 paparika User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 m 37 sec
Reputation Power: 6
Ohh cheers m8, understood that, move the Dim stuff to cmdstart and cmdstop, works a treat now, cheers m8

i can keep up with the lads now

many thanks

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > the stop watch program


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT