Referencing "Application.*"

  • Thread starter Thread starter Scupper
  • Start date Start date
S

Scupper

Certain "Imports" of classes change the frame of reference within a class
such that making calls to functions such as "Application.DoEvents()" and so
on becomes ambiguous and gives a "Reference to a non-shared member requires
an object reference" error on Build.

This should be easy to figure out, but I am having no luck: How do I
reference these "generic" events if I have to do an Import like that?

I have tried <application name>.DoEvents() and <class name>.DoEvents() but
nothing seems to work.

Thanks.
 
Application.DoEvents()

See below . . . Regards - OHM#


Private stopMe as Boolean = False
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

stopMe = True

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click

Dim i As Int32

While stopMe = False

Application.DoEvents()

Debug.WriteLine(i)

i += 1

End While

End Sub

Certain "Imports" of classes change the frame of reference within a
class such that making calls to functions such as
"Application.DoEvents()" and so on becomes ambiguous and gives a
"Reference to a non-shared member requires an object reference" error
on Build.

This should be easy to figure out, but I am having no luck: How do I
reference these "generic" events if I have to do an Import like that?

I have tried <application name>.DoEvents() and <class
name>.DoEvents() but nothing seems to work.

Thanks.

Regards - OHM# (e-mail address removed)
 
Thanks, but I'm not sure how this addresses my question ...

I understand how to use DoEvents. The problem is that when I add an
Import to the class, such as "Word.ApplicationClass" or something, that
has an "Application" type, I can no longer call "Application.*"
functions as you show below, as I get a "Reference to a non-shared
member requires an object reference" error when I build the application.
I'm wondering how to call them when I cannot use that syntax.
 
Sorry, you have to instantiate a new application object before you can
reference it.

Private WordApp As New Word.ApplicationClass



OHM#

Thanks, but I'm not sure how this addresses my question ...

I understand how to use DoEvents. The problem is that when I add an
Import to the class, such as "Word.ApplicationClass" or something,
that has an "Application" type, I can no longer call "Application.*"
functions as you show below, as I get a "Reference to a non-shared
member requires an object reference" error when I build the
application. I'm wondering how to call them when I cannot use that
syntax.

Regards - OHM# (e-mail address removed)
 
But how do I refer to the Application object for my own app (rather than
the Application object when there are multiple references that have
Application objects?

The prog doesn't know whether I mean "Word.Application.DoEvents()" or
something else specific to my app. How do I tell it "<my
application>.Application.DoEvents()"? Or some "generic" DoEvents, referring
to the whole process?
 
Scupper said:
But how do I refer to the Application object for my own app (rather
than the Application object when there are multiple references that
have Application objects?

The prog doesn't know whether I mean "Word.Application.DoEvents()" or
something else specific to my app. How do I tell it "<my
application>.Application.DoEvents()"? Or some "generic" DoEvents,
referring to the whole process?

System.Windows.Forms.Application.DoEvents

see also:

http://msdn.microsoft.com/library/en-us/vbcn7/html/vaconAvoidingNamingConflicts.asp

and: (sub topics 4.7.1 and 4.7.2)

http://msdn.microsoft.com/library/en-us/vbls7/html/vblrfVBSpec4_7.asp
 
Back
Top