Load Problem

JJKazJr

Newcomer
Joined
Jul 28, 2006
Messages
17
Location
Milwaukee, WI
Ok, here's the problem. I have a form(a) which I am calling from another form(b). when form(a) is loaded i have a set of code that is set to run. Now form (a) is launced by double clicking on a chart in form (b) using forma.show.

The problem is this: form(a) only loads half the time.

Half the time I attempt to load form(a) the code set to run on load is activated and runs but does not show the form, the other half it shows the form but does not run the code. I am really confused. Any ideas?

Thanks
 
Showing some code might have been helpfull so we can see exactly whats going on. I suspect your problem is this. The OnLoad method is only called when the page is first loaded not everytime you call a forms .Show() method. Thus whenever you are creating the form and then calling Show() the OnLoad event is triggered. But if the object it already Initialised the OnLoad event isn't triggered.
 
Okay, that may explain part of the problem, but it isn't called on the first time and then not again. The code (ChartChangeForm_Load) runs every odd time that the .show command is ran through. In addition, the ChartChangeForm doesn't show. On the even times that I call the .show command, the form will show, but not run the code. I could see the Load function not being called because of your reasoning, but it doesn't even load up the form half the time.

Here's my code.
Visual Basic:
Private Sub TLeftChart_DblClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles TLeftChart.DblClick
        ActiveControl.Tag = 1
        ChartChangeForm.Show()
End Sub
Private Sub ChartChangeForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim x As Int16
        For x = 0 To 3
            If chartset(x).Tag = 1 Then
                MsgBox("Yeah")
                chartset(x).Tag = Nothing
                Exit For
            End If
        Next
        Me.Datebox.Value = ddt
    End Sub

Each sub is in their related forms, I just grouped them here to show both.
 
If you're using 2005, and the Load Event is the problem, the code might be better off in the Shown event which runs every time the form is shown.
 
Back
Top