Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 2005 > Pro Visual Basic 2005
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Pro Visual Basic 2005 For advanced Visual Basic coders working in version 2005. Beginning-level questions will be redirected to other forums, including Beginning VB 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro Visual Basic 2005 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old September 21st, 2006, 04:30 AM
Registered User
 
Join Date: Sep 2006
Location: Beijing, , China.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Reference between child window of MDI in vb 2005

The interface of my MDI Program:

My MDI program code source:
¡® This is the MDI main window (the container), use it¡¯s menu option to open the child window as many as you want.
Public Class frmMdi

    Private Sub mNewSub1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mNewSub1.Click
        Dim f As New frmSub1
        f.MdiParent = Me
        f.Show()
    End Sub

    Private Sub mNewSub2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mNewSub2.Click
        Dim f As New frmSub2
        f.MdiParent = Me
        f.Show()
    End Sub
End Class

¡® Child window 1. From here, want to call the function or excute the procedure in child window 2.
Public Class frmSub1

    ' Call the function named fSum in child window 2.
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        For Each f As Form In frmMdi.MdiChildren
            If TypeOf f Is frmSub2 Then ¡® see Note
                ' I want to call fSum in f, something like this: textbox1.text=f.fSum(4)
                ' but it is no fSum object in f. How can explore the fSum object in frmSub2?
            End If
        Next
    End Sub
¡®Note: In practice, I have to use another IF statement within this IF statement to locate one of the frmSub2

    ' Excute the procedure named pSum in child window 2.
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        ' Same problem, how to explore the pSum object in frmSub2 and can excute it here.
    End Sub
End Class

¡® Child window 2. have the function and procedure being called or excuted by child window 1.
Public Class frmSub2

    Friend Sub pSum(ByVal j As Integer)
        Dim i As Integer, sum As Integer

        For i = 1 To j
            sum = sum + i
        Next
        TextBox1.Text = sum
    End Sub

    Friend Shared Function fSum(ByVal j As Integer) As Integer
        Dim i As Integer

        For i = 1 To j
            fSum = fSum + i
        Next
    End Function

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        TextBox1.Text = fSum(Val(TextBox1.Text))
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Call pSum(TextBox1.Text)
    End Sub
End Class



 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Displaying MDI Child Form Menus with MDI Parent ashu_from_india Pro VB 6 3 June 11th, 2008 12:01 AM
Controlling MDI child form from MDI parent panel LuxCoder VB.NET 2002/2003 Basics 7 April 11th, 2007 03:38 PM
Again: Reference between child window of MDI ly_he Pro Visual Basic 2005 1 September 25th, 2006 10:40 PM
Opening MDI Child on Button Click of MDI Child Sachin Shinde Visual Studio 2005 0 June 8th, 2006 06:05 AM
Mdi child window minimizes vsramiya Pro VB 6 2 October 28th, 2005 08:32 AM



All times are GMT -4. The time now is 10:48 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.