VB to .NET Mental Migration Problems
Hi!
Having programmed primarily in VB6(3,4,5), moving to .Net has had it's challenges!
Specifically, in VB6 I use:
In a module:
Public Frm As Form
in Form1:
Set Frm = New Form2
Frm.Show
Frm.List1.Additem (what-ever)
The above works perfectly.
But in VB.Net 2005, how is this accomplished?
Can anyone point me the right direction?
Thanks!
Re: VB to .NET Mental Migration Problems
In vb.net that would probably be like this:
Code:
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim frm As New frmList
frm.Show()
frm.ListBox1.Items.Add("Hi")
End Sub
Re: VB to .NET Mental Migration Problems
This depends how you want to use the form. For example, I often you the following structure so I can control exactly how my forms are displayed
Code:
Private Withevents mFwhatever as frmWhatever
Private Sub ShowForm()
If mFwhatever is Nothing then
mFwhatever = new frmWhatever
'Any preperation here
mFwhatever.Show()
Else
mFwhatever.Focus()
End If
End Sub
Private sub frmMain_Closing(.....
'Shut down any open child forms
If mFwhatever IsNot Nothing Then mFwhatever.close
End Sub
Private Sub mFwhatever_closed(.......
mFwhatever = nothing
End Sub
Hope that helps!