CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Thread: user control

  1. #1
    Join Date
    Jun 2001
    Posts
    28

    user control

    Hi All!

    I Need Help for user control.

    I am tring to call a "Form" from user control
    but it is giving error.

    In user control I wrote this code

    Sub cmdOk_click()

    frmTest.Show vbModal, Me
    If ModalOutput Then
    strMonth = frmTest.MonthView.Month
    strDate = frmTest.MonthView.Day
    else
    exit sub
    end if
    End sub

    The "Form" consists of "MothView control"

    Private Sub cmdOK_Click()
    ModalOutput = True
    Hide
    End Sub

    Is this Possible?

    If not what is requried?

    Thanks In Advance
    Anita




  2. #2
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210

    Re: user control

    What knd of error are you getting???
    THe Hide does not seem correct. Maybe it should be ME.Hide or FormName.Hide

    John G

  3. #3
    Join Date
    Jun 2001
    Posts
    28

    Re: user control

    Hi!

    I am getting 2 errors.

    1. Run time error '424':
    Object requried

    2. Runtime Error '364':
    object was unloaded

    Anita


  4. #4
    Join Date
    Jun 2001
    Posts
    28

    Re: user control

    I tried this also

    In Module I added this code

    Public fTest as frmTest

    And in usercontrol

    Private Sub UserControl_Initialize()

    set fTest = new frmtest
    load fTest

    end if

    If I do this I am not able to place control on "Form"

    Error '91'
    Object or block variable not set

    Ofcourse I changed Hide as formname.hide

    Anita



  5. #5
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210

    Re: user control

    I may be wrong on this, but it looks like you have the frmTest outside of your user Control project. I think It must be contained within the User COntrol project.
    I have a Skeleton User Control sample that is structured like this and I have no problems

    + Skeleton Project(Skeleton.vbp)
    Form1(Form1)
    Skeleton(Skeleton.ctl)
    + TestProject(TestProject.vbp)
    Test (Test.frm)
    '
    'Test form calls Skeleton.ctl which does a Form1.Show with no problem.

    John G

  6. #6
    Join Date
    Jun 2001
    Posts
    28

    Re: user control

    Hi John,

    Thanks for replay.

    I am using a thirdparty control in Usercontrol.
    & I am tring to access that from "Form".(putting values into listbox-using that i am doing other process).

    If i don't access that component then it works but if I use
    set comp=NameofProject.component.method(or property)

    It gives error '9' while placing usercontrol on test form

    I am able to see methods & properties when I use
    ProjectName.

    Thanks,
    Anita


  7. #7
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210

    Re: user control

    I would get back to the author of the third party control for suggestions on how to do that. If you have no problems adding Microfost standard controls to the form, then I suggest it probably is inherent in the third party control.
    '
    '
    Suggestion. Try doing the same thing with a Microsoft supplied control to see what happens.

    John G

  8. #8
    Join Date
    Jun 2001
    Posts
    28

    Re: user control

    Thanks John!

    I passed that object to that form.
    It is working fine

    Anita


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

Featured