Results 1 to 10 of 10

Thread: [RESOLVED] DoEvents in class files

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2005
    Posts
    66

    Resolved [RESOLVED] DoEvents in class files

    How to call DoEvents in a class file? The project is compiled into a DLL and the class has no access to any forms.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: DoEvents in class files

    You can call it from a module in the app like ... Application.DoEvents, but I am not 100% sure about inside a dll?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2005
    Posts
    66

    Re: DoEvents in class files

    When I write Application.DoEvents() I get an error:

    Name 'Application' is not declared.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: DoEvents in class files

    Application.DoEvents() raises all pending events for the current application. It is a Shared method of the Application class, so no object reference is needed. Note that the Application class is a member of the System.Windows.Forms namespace, so your project must have a reference to the appropriate library. A Windows Control Library project will have that reference by default, but I think you'd have to add it yourself if your's is a Class Library project.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Aug 2005
    Posts
    66

    Re: DoEvents in class files

    Imports System.Windows.Forms

    Namespace or type 'Forms' for the Imports 'System.Windows.Forms' cannot be found.

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: DoEvents in class files

    Quote Originally Posted by itportal
    Imports System.Windows.Forms

    Namespace or type 'Forms' for the Imports 'System.Windows.Forms' cannot be found.
    I said you have to add a reference to your project. You cannot import a namespace for which you do not have a reference to its library.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Aug 2005
    Posts
    66

    Re: DoEvents in class files

    The DLL and the main project (where the exe file is) are different projects. The EXE has a refrence to the DLL, but how to link the DLL with the EXE?

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: DoEvents in class files

    That's not what I meant. I meant that you need to right-click your DLL project in the Solution Explorer, select Add Reference, then select System.Windows.Forms.dll from the .NET tab. This will add a reference to that assembly, which contains the System.Windows.Forms namespace and thus the System.Windows.Forms.Application class, to your DLL project. Then you can import the System.Windows.Forms namespace if you want and access all its members.

    Note that importing a namespace only means you don't have to qualify the names of its members in your code. It doesn't give you access to anything that you didn't have before.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Aug 2005
    Posts
    66

    Re: DoEvents in class files

    Sorry, I haven't understand you right It worked. Thanks a lot!

  10. #10
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [RESOLVED] DoEvents in class files

    All's well that works well.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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