CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2003
    Location
    Ft. Worth Texas
    Posts
    31

    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!

  2. #2
    Join Date
    Dec 2003
    Location
    Northern Ireland
    Posts
    1,362

    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
    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rich Cook


    0100 1101 0110 1001 0110 0011 0110 1000 0110 0001 0110 0101 0110 1100 0010 0000 0100 0101 0110 1100 0110 1100 0110 0101 0111 0010

  3. #3
    Join Date
    Aug 2005
    Location
    Imperial College London, England
    Posts
    490

    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!
    Help from me is always guaranteed!*
    VB.NET code is made up on the spot with VS2008 Professional with .NET 3.5. Everything else is just made up on the spot.
    Please Remember to rate posts, use code tags, send me money and all the other things listed in the "Before you post" posts.

    *Guarantee may not be honoured.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured