Results 1 to 2 of 2

Thread: OCX trouble

  1. #1

    Thread Starter
    Addicted Member Jazz00006's Avatar
    Join Date
    Feb 2006

    OCX trouble

    does anyone know how to make it so when i type into my compiled OCX it can show a form that the user has specified

    VB Code:
    1. function Showform(form as frm)
    3. end function

    just a quick summary

    but how would i make the ocx show a form? becuase when i try it (or something like that) it tells me that the form in not there (because its trying to get it from the OCX not the current project)

    Yess i do need it to be an OCX

    any help would be appreciated

  2. #2
    Join Date
    Oct 2002
    British Columbia

    Re: OCX trouble

    If you just want to Show the form you could do something like the following

    VB Code:
    1. 'in OCX
    2. Private mClientForm As Form
    4. Public Property Set DisplayForm(SomeForm As Object)
    5.     If Not SomeForm Is Nothing Then
    6.         If TypeOf SomeForm Is VB.Form Then
    7.            Set mClientForm = SomeForm
    8.         End If
    9.     End If
    10. End Property
    12. Private Sub Text1_KeyPress(KeyAscii As Integer)
    13.     If Not mClientForm Is Nothing Then
    14.         mClientForm.Show
    15.     End If
    16. End Sub
    18. 'In Form 1
    19. Private Sub Command1_Click()
    20.     Dim f As Form2
    21.     Set f = New Form2
    22.     Me.UserControl11.DisplayForm f
    23. End Sub

    It would be impossible for the OCX to create a new instance of a Form in another project (Forms and Controls are Private to the project and are not meant to be passed to other components).
    Last edited by brucevde; Apr 14th, 2006 at 01:48 AM.

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