Results 1 to 3 of 3

Thread: How do I test if an object has been instantiated?

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Location
    Greensboro, NC, USA
    Posts
    2
    Dim F as Form
    .
    .
    .
    Set F = frmSomeForm

    If I do a quick watch on F prior to the set statement being executed, vb tells me the value of F is Nothing. However if I attempt to code:

    If F = Nothing then
    .
    .
    .
    End If

    I get an "Invalid use of object error message". How would I test if the set statement has been executed (i.e. F has been instantiated)?

  2. #2
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    That is almost right, we use Is with objects though
    Code:
    If Not myObject Is Nothing Then
      'then the object exists
    Else
      'It is not initiated
    End If
    Iain, thats with an i by the way!

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Location
    Greensboro, NC, USA
    Posts
    2

    Talking

    Thanks a bunch!
    (I should have known/thought of that!)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width