tcomputerchip Posted December 3, 2002 Posted December 3, 2002 I want to be able to store all the iterations of the frmStatus in an object array, similar to if you had mutible documents opened in MS Word. I want to be able to call the forms though the array collection so that I can open and close them as needed. The project is setup with MDI Parent (frmServer) and MDI Child (frmStatus) [set in code]. When I check the Status(AvailableID) that it should have created the Object is still set to Nothing. This is what I have so far. 'Global Vars Dim Status() As frmStatus Dim AvailableID As Integer 'Sub In question? Private Sub mnuShowMDI_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuShowMDI.Click On Error Resume Next Dim FoundAvailable As Boolean FoundAvailable = False Do Until FoundAvailable = True If Status(AvailableID) Is Nothing Then 'Force Error FoundAvailable = True End If AvailableID = AvailableID + 1 Loop Status(AvailableID) = New frmStatus() Status(AvailableID).MdiParent = Me If AvailableID = 1 Then Status(AvailableID).Text = ":New Status Window" Else Status(AvailableID).Text = ":New Status Window[" & AvailableID & "]" End If Status(AvailableID).Show() End Sub Quote
*Gurus* Derek Stone Posted December 3, 2002 *Gurus* Posted December 3, 2002 You never redimension the array. As it stands it'll always have zero elements. No elements equates to no forms. Quote Posting Guidelines
*Gurus* Derek Stone Posted December 3, 2002 *Gurus* Posted December 3, 2002 And for God's sake get rid of the "On Error Resume Next" line. Use a Try/Catch block instead, only if need be. Quote Posting Guidelines
tcomputerchip Posted December 4, 2002 Author Posted December 4, 2002 Hey, you don't need to batter my code. This is my 4th program I am revising from over 50,000 lines of code. Im not worried about error trapping at this point. I know how to find the error. I have never used any of the new programming structure so I did not know about Try/Catch. If you are willing explain what you are so eger to bash I would be greatfull. Also, I do not know what you are talking about with the Redemension of the Array. I know how to do it in VB 6 but I though ReDim was removed from .NET. Please explain in more detail. Quote
*Experts* Bucky Posted December 4, 2002 *Experts* Posted December 4, 2002 ReDim is still alive and kickin' in .NET, and it works the same way (ReDim theArray(newArraySize)), along with ReDim Preserve. Quote "Being grown up isn't half as fun as growing up These are the best days of our lives" -The Ataris, In This Diary
*Gurus* Derek Stone Posted December 4, 2002 *Gurus* Posted December 4, 2002 Dim iInteger As Integer Try 'Cause a divide by zero error iInteger = 7 / 0 Catch e As DivideByZeroException 'Catch the error Catch ex As Exception 'Catch other errors End Try Quote Posting Guidelines
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.