|
-
Jul 26th, 2005, 02:53 AM
#1
Thread Starter
Member
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.
-
Jul 26th, 2005, 05:23 AM
#2
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.
-
Jul 26th, 2005, 07:21 AM
#3
Re: Dll Class
This looks like Classic VB code (If not my comments might not make much sense)
 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|