Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB 6
|
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 28th, 2009, 12:45 PM
Authorized User
 
Join Date: Aug 2008
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default need help with the below logic/code

need help with the below logic/code

')))))))))))))))))))))

'form2

Private Sub Command1_Click()
Unload Form2

Form3.Show
End Sub

')))))))))))))))))))))

'form3

Private Sub Form_Load()

Timer1.Enabled = True
Counter = 5

End Sub


Private Sub Timer1_Timer()

Counter = Counter - 1 'we set the counter to count here

Text3.Text = Counter

'If Text3.Text = 0 Then
'MsgBox ("DONE")
'Unload Me
'End If

End Sub

'----------------

what happens is that "Sub Timer1_Timer()" never execited. the focus goes from the first End Sub in form3 to the End Sub in form2 and thats it, nothing happens. "Private Sub Timer1_Timer()" never executes. need some help here pls..
 
Old February 28th, 2009, 03:39 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Hi there..

without running the code, I can see some flaws.

form2 is never unloaded since you are unloading it from inside itself, instead of raising an error (which seems more logical), vb just doesn't unload it and continue executing it code.

You are enabling the timer in the load (don't understand why, just put the control enable by default). It can be the case that the control is not loaded, so it still came disable by default. Also, did you set the timer event to excute every how much ms???
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
 
Old March 1st, 2009, 01:53 AM
Authorized User
 
Join Date: Aug 2008
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

changed the code to:

'**********************************
'form3

Private Sub Form_Load()

Counter = 5

End Sub


Private Sub Timer1_Timer()

Counter = Counter - 1

Text3.Text = Counter

End Sub

'*************************************

now what happens is the the value of "counter" is always 0 in Timer1_Timer() even though it has been initialized to 5 in Form_Load(). so i am getting -1 as the value in counter when i run the code.
 
Old March 1st, 2009, 10:44 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Hi there..

That's probably because you never dimmed counter as form level?? didn't you??

First at all, put option explicit at top of every form. Rigth now, counter variables is initialized twice (once in the form load, then in the timer event).

Second do something like dim counter as integer at form level.

Then you will be ready to go.

Are you learning VB6 or making some kind of project?
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
grouping logic mike123 XSLT 7 October 27th, 2007 01:20 PM
And/Or Logic??? ninel SQL Server 2000 2 February 9th, 2007 11:33 AM
RECURRING LOGIC its.shashank Classic ASP Databases 1 November 22nd, 2006 08:58 AM
Might this be a logic error due to the code? Ben Horne Javascript 1 November 30th, 2004 08:59 PM
Mixing Data access logic and business logic polrtex BOOK: Professional Jakarta Struts 0 December 15th, 2003 07:19 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.