trying to create simple class

Discussion in 'AutoCAD' started by Mark Propst, Jul 5, 2003.

  1. Mark Propst

    Mark Propst Guest

    Hi,
    well I thought I knew how to do this but it's not working.
    I'm just trying to get a simple class started.
    vb6 new activexdll project
    add one class module named adcxDbx.cls
    add one standard exe module named testdbxClass.bas
    startup object = sub main

    references = {'these came up as checked by default - I don't know if i need
    them all:}
    visual basic for applications
    visual basic runtime objects and procedures
    visual basic objects and procedures
    ole automation
    'then I added these
    autocad2000 type lib
    objectdbx 1.0 type lib


    in the std mod:
    Option Explicit
    'declare module level variable so other subs can also run and refer to db
    'once it's been created
    Dim db As adcxDBX

    Sub main()
    Set db = New adcxDBX
    If Not db Is Nothing Then
    db.Hello
    MsgBox "Drawing open"
    Else
    MsgBox "Failed to create class"
    End If
    Set db = Nothing
    End Sub

    in the class module
    (among other subs)
    Option Explicit

    Private oDbx As AXDB15Lib.AxDbDocument
    Sub Hello()
    Debug.Print "start"
    MsgBox "Hello"
    End Sub

    when i run main (from the ide with the run button on toolbar)
    it looks like something is starting but nothing happens(just the run button
    is greyed and the continue and reset buttons are enabled) but the hello
    function doesn't run, no message box and no error message box either for the
    if not db is nothing clause
    so it seems to just be sitting there waiting for something and I have to
    cancel with the reset button
    What am I missing
    Is it not possible to test a dll from the ide? do I need to compile and call
    from another sub?
    Thanks for any hints
    Mark
     
    Mark Propst, Jul 5, 2003
    #1
  2. Mark Propst

    Tim Jendro Guest

    Hi Mark,

    I have tested quite a few dll's in the ide. The way that I do it is to have
    the application project that is going to call the dll open in the ide. Then
    go to File|Add project and then select the dll project. This opens both of
    the projects in the same ide. You can step through everything so that you
    can see what is causing the error.

    This may not help at all in tracking down your specific problem. I am
    responding to your question about testing dll's in the ide.

    Hope this helps.
     
    Tim Jendro, Jul 7, 2003
    #2
  3. Mark Propst

    Mark Propst Guest

    Right, but you have to compile the dll first, right?
    That was what I was missing first, I was trying to test the dll code from
    within the dll module before compiling.
    After reading the help I realized that I had to compile the dll, write a
    separate module to call it, and test from that module.
    But when I modify the dll, before saving changes I have to uncheck the
    reference in the calling module - small incovenience, is there any way
    around that?
     
    Mark Propst, Jul 7, 2003
    #3
  4. Mark Propst

    Tim Jendro Guest

    No, I dont think you need to recompile the dll if you have both projects
    open in the ide at the same time. When I have ever created a dll, I have
    created the structure of the dll (class with properties and methods defined)
    and save. I didnt create any of the code yet other than creating the
    property gets and lets, etc... I would close and start a new project from
    scratch, add a single button to the form and then through that button click
    event I would create a new instance of my dll. Before I run for the first
    time I make a reference to my dll in the new project and I also add the dll
    by the method I stated in the previous post (File|Add Project) to the ide.
    This way, when I run through the debugger, I can step through the button
    click of the form and that will let me step into the dll code that is open
    in the ide. This has never posed any issues for me. It is very easy then
    to test code in the dll methods. There is also a "Start with full compile"
    (CTRL + F5) option under the Run pulldown menu.

    When working with both projects in the ide, I have never found in necessary
    to change the reference or to do anything with the dll in a separate space.
    Once my modifications are complete, I would then recomile the dll. When
    starting my application by itself, I would then get a message that my dll
    version had changed and it would prompt me that it (the vb ide) would use
    the new version.
     
    Tim Jendro, Jul 7, 2003
    #4
  5. Mark Propst

    Mark Propst Guest

    that would be very cool, I'll try that out when I get time
    THanks
    Mark
     
    Mark Propst, Jul 7, 2003
    #5
  6. Mark Propst

    Mark Propst Guest

    Thanks much!
    I'll give that a try,that sounds like what I was hoping to be able to do
    Mark
     
    Mark Propst, Jul 8, 2003
    #6
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.