User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Visual Basic 4 / 5 / 6 section within the Software Development category of DaniWeb, a massive community of 456,428 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,602 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums
Views: 1102 | Replies: 11
Reply
Join Date: Jun 2007
Posts: 52
Reputation: anud18 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
anud18 anud18 is offline Offline
Junior Poster in Training

event handling

  #1  
Jun 20th, 2007
how do i make the programme wait untill a particular event happens......

i read it on the msdn....that by inserting "App.WaitForEvents" where i wanted to make my programme wait for the event i could do it.....

but when i tried putting this line in the programme the compiler didnt recognize the WaitForEvents method.....

can anybody help me out with any other alternative???
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2007
Posts: 166
Reputation: AV Manoharan is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 7
AV Manoharan AV Manoharan is offline Offline
Junior Poster

Re: event handling

  #2  
Jun 20th, 2007
See, every control event is associated with the form at the design time itself and when it become activated it automatically wait for all control events associated with that form. Why, you want specifically mention in your program to wait for the control to happen I can't understand. Please do explaine a little further. If it is for some other event such as Mouse focus,drag etc. or triggers fired you can make your application to wait for those things.
Last edited by AV Manoharan : Jun 20th, 2007 at 8:47 am.
Reply With Quote  
Join Date: Jun 2007
Posts: 52
Reputation: anud18 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
anud18 anud18 is offline Offline
Junior Poster in Training

Re: event handling

  #3  
Jun 20th, 2007
when what becomes activated???....the form or the control event....i couldnt understand
Reply With Quote  
Join Date: Jun 2007
Posts: 166
Reputation: AV Manoharan is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 7
AV Manoharan AV Manoharan is offline Offline
Junior Poster

Re: event handling

  #4  
Jun 20th, 2007
Again see, there are events associate with your form which are known as control events. ie. when command is clicked etc. OK. There are other events such as connection events, mouse events, objects state property etc. etc
More over there is EventStatusEnum. having values to understand.

For a particlar object to trap the events you have to specifically mention during the declaration time eg. a connection event is declared below.

Dim WithEvents CNN. as ADODB.Connection
Set CNN = New ADODB.Connection


Then you can trap this even as below

Sub CNN_ExecuteComplete(. . .)
If pError.Number<> 0 Then
..handle error here
Else
...Proceess your recordset
End If
End Sub

Beware the above code will give you error if pError doesn't happen
for that you have to check adStatus <>adStatusOK then you can examin the number property of the pError..

That's ok

simply you can ask your object CNN to wait as below
for that you have to instatiate another ADODB method ie Command

Dim myCommand as new ADODB.Command

Then you can carry on checking its status as below

While myCommand.State = AdStateExecuting

DoEvents

Wend
Debug.Print "Command1 Executed"

The program wait for the event to finish
then it prints the message

Too much I hope. But it will give you some idea.
Please get back to me. Send message so that i will be notified.
Last edited by AV Manoharan : Jun 20th, 2007 at 9:27 am.
Reply With Quote  
Join Date: Jun 2007
Posts: 52
Reputation: anud18 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
anud18 anud18 is offline Offline
Junior Poster in Training

Re: event handling

  #5  
Jun 21st, 2007
i tried out the command thing also sir....but it is not working out that ways also ....

its not waiting gor events to happen...
Reply With Quote  
Join Date: Jun 2007
Posts: 166
Reputation: AV Manoharan is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 7
AV Manoharan AV Manoharan is offline Offline
Junior Poster

Re: event handling

  #6  
Jun 21st, 2007
Please send me the piece of code. I can't understand you at all. You are talking something else, other than waiting for some event to finish.
Reply With Quote  
Join Date: Jun 2007
Posts: 52
Reputation: anud18 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
anud18 anud18 is offline Offline
Junior Poster in Training

Re: event handling

  #7  
Jun 21st, 2007
actually sir .....after calling th showform function present in the dll....i want the programme to wait for the user to click on the command button(event)......

in the command_click event i have put the follwing code

Public Sub Login_Click()

Dim Ctr As Integer
Ctr = 0
For Ctr = 0 To (Form1.CboUserName.ListCount - 1) Step 1

If Form1.Text1.Text = Form1.CboUserName.List(Ctr) And Form1.Text2.Text = Form1.CboPassword.List(Ctr) Then
Validate = True

Else
Validate = False

End If


Next

End Sub

Now based on the value fo this integer variable Ctr1 , i want to proceed further as

If Ctr1=1
KRN_StartForm 'another function
Else MsgBox "Access Denied

these above four lines are present in the module of the project....

but what is happening is the programme is not waiting for the user to click the command button....rather it takes the value of Ctr1=0 and shows "access denied"......
Reply With Quote  
Join Date: Jun 2007
Posts: 166
Reputation: AV Manoharan is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 7
AV Manoharan AV Manoharan is offline Offline
Junior Poster

Re: event handling

  #8  
Jun 21st, 2007
Earlier I asked you a simple question whether the Login in your Login_click()
is actually the NAME of the control or it's CAPTION
Reply With Quote  
Join Date: Jun 2007
Posts: 52
Reputation: anud18 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
anud18 anud18 is offline Offline
Junior Poster in Training

Re: event handling

  #9  
Jun 21st, 2007
its the name as well as the caption
Reply With Quote  
Join Date: Jun 2007
Posts: 166
Reputation: AV Manoharan is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 7
AV Manoharan AV Manoharan is offline Offline
Junior Poster

Re: event handling

  #10  
Jun 21st, 2007
Originally Posted by anud18 View Post
its the name as well as the caption

OK. how the form is exited? Is it visible.?
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Visual Basic 4 / 5 / 6 Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum

All times are GMT -4. The time now is 1:17 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC