Form Load Event runs 3 times

V

Vayse

My Load event is running 3 times.
I'm calling the form two different ways, and it always runs 3 times. As you
can imagine, this makes the load time slow!
Any help appreciated.
Vayse


Method 1:
Dim fAsset As New frmAsset

fAsset.AssetView = fAsset.ViewAsset
fAsset.AssetCode = stAssetCode
fAsset.Show()

Method 2:
Dim fAsset As New frmAsset

fAsset.AssetView = fAsset.ViewAll
fAsset.Show()



'********************************************************************
Private Sub frmAsset_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load, MyBase.Load, MyBase.Load

Me.ScheduleTableAdapter.Fill(Me.AssetsDataSet.Schedule)
Me.MethodsTableAdapter.Fill(Me.AssetsDataSet.Methods)
Me.SubCatgsTableAdapter.Fill(Me.AssetsDataSet.SubCatgs)
Me.StatusTableAdapter.Fill(Me.AssetsDataSet.Status)
Me.SuppliersTableAdapter.Fill(Me.AssetsDataSet.Suppliers)
Me.DeptsTableAdapter.Fill(Me.AssetsDataSet.Depts)
Me.CostCentresTableAdapter.Fill(Me.AssetsDataSet.CostCentres)

iOpened += 1
Try
Select Case iAssetView
Case conVIEW_ASSET
Debug.Print(iAssetView & ": One & " & iOpened)
Me.AssetsTableAdapter.FillByAsset(Me.AssetsDataSet.Assets,
stAssetCode)
Case conVIEW_SUB
Debug.Print(iAssetView & ": Sub & " & iOpened)
Me.AssetsTableAdapter.FillBySub(Me.AssetsDataSet.Assets,
lSubCatgID)
Case Else
Debug.Print(iAssetView & ": All & " & iOpened)
Me.AssetsTableAdapter.Fill(Me.AssetsDataSet.Assets)
End Select
Catch ex As System.Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try

bLoaded = True

End Sub
 
C

Chris Petchey

Vayse said:
Private Sub frmAsset_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load, MyBase.Load, MyBase.Load


I draw your attention to the "Handles" part of your statement
 
V

Vayse

And now that I review my mail, I see why!
For some reason, theres 3 mybase.load
Handles MyBase.Load, MyBase.Load, MyBase.Load

I wonder how I did that?
Vayse
 
P

Peter Huang [MSFT]

Hi

I did not understanding your scenario very clear, what is your question now?
If you still have any concern, please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top