borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Passing values from a FORM to a usercontrol (both of them are in thesame activex project))Next Topic (Component Request Pending) New Topic New Poll Post Reply
AndreaVB Forum : ActiveX : passing objects in ocx control
Poster Message
anandanatarajan
Level: Trainee

Registered: 26-01-2005
Posts: 1

icon passing objects in ocx control

hello friends
i would like to know is there any possibilty to pass form as a object in a public function in ocx.
i.e.
public sub loadText(mfrm as form)

'code goes here

end sub
i wish to use some codings like this but while compling it retruns an error like public objects cannot be compiled in an public declared active x control

is there any idea or solution
regards


____________________________
Vidhya Dharmena Shobathe [education worths only in combination with truth]

26-01-2005 at 08:51 AM
View Profile Send Email to User Show All Posts | Quote Reply
vbgen
Level: Moderator

Registered: 10-10-2002
Posts: 876
icon Re: passing objects in ocx control

try to post your code, so we can determine the code source problem.

____________________________
Been busy trying to take a second degree <--it's not working out...

02-02-2005 at 03:26 PM
View Profile Send Email to User Show All Posts | Quote Reply
jonybd
Level: Master

Registered: 18-01-2005
Posts: 115
icon Re: passing objects in ocx control

if you have a object compiled as ocx , and
useing components add it to your forms

Example: Command1

private sub command_click()
  command1.MyFunction "helo World"
end sub


____________________________
Telecommunication programmer.
Sip, Isdn - technology.

08-02-2005 at 08:37 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
Andy214
Level: Trainee

Registered: 26-12-2003
Posts: 3
icon Re: passing objects in ocx control

For ActiveX project, to pass controls like Forms, TextBox, etc... you can only use late binding, e.g. declare as Object

Public Sub DoSomething(frm As Object)
...
End Sub

To further make sure the object is the one you expect, you can do type checking in your code (e.g.)

If TypeOf frm Is Form Then

End If


NOTE:
There's a problem tough I notice, is when I have 2 development PC, say A and B, and I have compile the OCX on both PC before.
When I compile in PC A, then I bring the project (with OCX) to PC B to continue development, no error BUT the OCX didn't work as expected (I'm using Binary Compatibility, and in the OCX I passed in a control which then I checked if the TypeOf matches the control I will set reference to).
What I mean by didn't work as expected is, it didn't SET the variable in my OCX to the object passed in in PC B, but its working fine in PC A.
When I re-compile in PC B, it works fine already, but when I bring back to PC A, it's not working as expected AGAIN, I have to recompile...

So, I decided to use Debug.Print to let me know what is actually happening.

I notice this, let say I pass in a TextBox object, during checking of TypeOf (e.g. TypeOf ctrlpassedin Is TextBox)
1. In the SAME development PC I compile, it returns TRUE.
2. In the other development PC, it returns FALSE. (When it's actually a TEXTBOX!)

Any ideas?? I think it has something to do with the registry settings (when you compile)... or its just another VB Bug?


____________________________
-Andy214-

29-09-2005 at 07:55 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : ActiveX : passing objects in ocx control
Previous Topic (Passing values from a FORM to a usercontrol (both of them are in thesame activex project))Next Topic (Component Request Pending) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder