Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: help debugging "object required" error


Message #1 by "Pierre du Toit" <greywacke@f...> on Mon, 29 Jul 2002 09:35:41
Pierre,

remember that VB (the evil one, not the good one :) evaluate all the
conditions in an if statement. To be sure that you do not access 
empty objects, instead of

if not myObject is null and myObject.Something then
endif

you have to do:

if not myObject is null then
   if myObject.Something then
   endif
endif

That makes the code also **much much** easier to debug...

Marco

-----Original Message-----
From: Pierre du Toit [mailto:greywacke@f...]
Sent: Monday, July 29, 2002 2:36 AM
To: professional vb
Subject: [pro_vb] help debugging "object required" error


i am receiving a "object required" error with this if statement.  
DCTimeTxt is a textbox, with the text value in the same format as given by 
time - in this case i am testing with "6:55:00 AM" as the value of the 
textbox.  optionR7DC is a checkbox object (Specifying wether it must 
disconnect or not), and weekdaychk is an array of textbox objects 0 to 6, 
being Sunday to Monday.  Here is is the code that is giving the error, it 
gets executed once every 1000 ms by a timer object, mnuDisconnect_Click is 
the click event of a menu object where it terminates all RAS connections 
(Dial-Up connections), i cannot find out what is wrong with the following 
code:

'--------------------------------------------------------------------
If time >= TimeValue(DCTimeTxt.Text) And _
   time <= DateAdd("N", 1, TimeValue(DCTimeTxt.Text) And _
   optionR7DC.Value = 1 And _
   weekdaychk(CInt(weekday(Date, vbSunday)) - 1)).Value = 1 Then
        Call mnuDisconnect_Click
End If
'--------------------------------------------------------------------

  Return to Index