Results 1 to 3 of 3

Thread: Dll Class

  1. #1

    Thread Starter
    Member
    Join Date
    May 2003
    Posts
    53

    Dll Class

    Hello Friend

    Please help me out

    Dll Class

    Private Sub Class_Initialize()
    Dim ScaleFactorX As Single, ScaleFactorY As Single ' Scaling factors
    ' Size of Form in Pixels at design resolution
    DesignX = 1024
    DesignY = 768
    End Sub

    Public Sub Res_Change(ByRef MyFrm As Object)
    Dim MForm As Form
    Set MForm = MyFrm
    MForm.ScaleMode = 1
    MyForm.Height = MForm.Height ' Remember the current size
    MyForm.Width = MForm.Width

    End Sub

    After creating Dll, I am using in normal Standard exe program as

    Command1_Click()
    Dim Fr As Object
    Set Fr = Nothing
    Dim F As New Resolution_Screen
    F.Res_Change (Fr)
    end sub

    When executing the above code gives an error object variable not set...

    Pleae let me know where am I wrong.

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

    Re: Dll Class

    Am I missing something? Is this VB.NET code? What's with the use of "Set"?

    It looks like you are explicitly setting your "Fr" variable to Nothing, passing it to a method and then trying to use its properties. If the variable does not refer to an object then there are no properties to use.
    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

  3. #3
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Dll Class

    This looks like Classic VB code (If not my comments might not make much sense)

    Quote Originally Posted by bobbynad
    Public Sub Res_Change(ByRef MyFrm As Object)
    Dim MForm As Form
    Set MForm = MyFrm
    MForm.ScaleMode = 1
    MyForm.Height = MForm.Height ' Remember the current size
    MyForm.Width = MForm.Width

    End Sub
    You forget (or don't realise) that when Res_Change exits, your MForm object goes out of scope and is destroyed, so it is useless. It should be declared Private in your declarations area at the top of the class.

    Command1_Click()
    Dim Fr As Object
    Set Fr = Nothing
    Dim F As New Resolution_Screen
    F.Res_Change (Fr)
    end sub

    When executing the above code gives an error object variable not set...
    You are declaring an object, setting it to Nothing (which is pointless seeing as that is what it is initialised to anyway ) and then passing it as a method parameter. It needs to be explicitly assigned as a reference to an existing or a newly instantiated object in order to be used as a parameter.


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