VB 6 LOAD form to VB.NET Question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michael Erlewine

    VB 6 LOAD form to VB.NET Question

    I am trying to learn VB.Net and can't figure out how to call a from from
    another form. In VB6, I just issue a Load FormX, and an Unload FormX... and
    Show the form and there it is.

    I am sure it is obvious, but I can't see how to do that in VB.net. Does
    someone have a piece of code that will call a from from another form and
    have it appear.

    Thanks,

    Michael Erlewine
    michael@erlewin e.ent


  • jo0ls

    #2
    Re: VB 6 LOAD form to VB.NET Question

    "Michael Erlewine" <michael@erlewi ne.net> wrote in news:BQGMd.2650 3
    $1E2.2250@fe06. lga:
    [color=blue]
    > I am trying to learn VB.Net and can't figure out how to call a from from
    > another form. In VB6, I just issue a Load FormX, and an Unload FormX...[/color]
    and[color=blue]
    > Show the form and there it is.
    >
    > I am sure it is obvious, but I can't see how to do that in VB.net. Does
    > someone have a piece of code that will call a from from another form and
    > have it appear.
    >
    > Thanks,
    >
    > Michael Erlewine
    > michael@erlewin e.ent
    >
    >
    >[/color]

    dim f2 as new form2
    f2.show
    'once f2 closes we return here
    'f2 is still available, and could be shown again
    'we can get info from f2 still:
    myString = f2.TextBox1.tex t
    'dispose will get rid of the form
    f2.dispose

    Comment

    • Pete Wright

      #3
      Re: VB 6 LOAD form to VB.NET Question

      j00ls code does the trick, but it's worth explaining.

      In .NET everything you work with is an object. So, when you add a form to
      your project what you are creating is a class containing code that defines
      the look, feel and behaviour of the form. To load the form then, you have to
      instantiate the class. It's the same as if I'd defined a class called Pete
      and wanted an object from it

      Dim myPete as New Pete()

      That turns my Pete class into an object. So, if you have a form class called
      Form2 (as in J00ls code) you'll need to first turn that class into an object

      Dim myForm as new Form2()

      Then, having turned it into an object, you can go ahead and call methods on
      it, like Show()

      myForm.Show()


      Hope that makes sense. Take a look at the programming with objects guides in
      the online help for more info on how to do OO with VB.NET. It's weird at
      first when you move across from VB6, but ultimately it makes a lot more
      sense than the old VB6 way of doing things.



      --
      Pete Wright
      Author of ADO.NET Novice to Pro for Apress




      "Michael Erlewine" <michael@erlewi ne.net> wrote in message
      news:BQGMd.2650 3$1E2.2250@fe06 .lga...[color=blue]
      >I am trying to learn VB.Net and can't figure out how to call a from from
      >another form. In VB6, I just issue a Load FormX, and an Unload FormX... and
      >Show the form and there it is.
      >
      > I am sure it is obvious, but I can't see how to do that in VB.net. Does
      > someone have a piece of code that will call a from from another form and
      > have it appear.
      >
      > Thanks,
      >
      > Michael Erlewine
      > michael@erlewin e.ent
      >[/color]


      Comment

      • Herfried K. Wagner [MVP]

        #4
        Re: VB 6 LOAD form to VB.NET Question

        Michael,

        "Michael Erlewine" <michael@erlewi ne.net> schrieb:[color=blue]
        >I am trying to learn VB.Net and can't figure out how to call a from from
        >another form. In VB6, I just issue a Load FormX, and an Unload FormX... and
        >Show the form and there it is.[/color]

        There is no 'Load' and 'Unload' any more. Forms in .NET are "normal"
        classes.

        Showing a form:

        \\\
        Dim f As New FooForm()
        f.Show()
        ///

        Showing a form modally:

        \\\
        Dim f As New FooForm()
        f.ShowDialog()
        f.Dispose()
        ///

        Notice that forms which are shown modally are not disposed automatically
        when they are closed, that's why you should call 'Dispose' explicitly.

        --
        M S Herfried K. Wagner
        M V P <URL:http://dotnet.mvps.org/>
        V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

        Comment

        • Michael Erlewine

          #5
          Re: VB 6 LOAD form to VB.NET Question

          Thanks all of you for that first step, which brings me to the gate of
          the second step: How do I create that 2nd form to be loaded?

          In VB6, I just ADD a blank form, populate it with controls, and then
          call it. How do I do that in VB.net

          Thanks,

          Michael Erlewine

          *** Sent via Developersdex http://www.developersdex.com ***
          Don't just participate in USENET...get rewarded for it!

          Comment

          • Michael Erlewine

            #6
            Re: VB 6 LOAD form to VB.NET Question

            I got the Form to load and I figured out how to ADD A FORM to the
            project. I have another question.

            Much of my work is in FoxPro. All I need is to read a FREE .DBF table,
            and transfer the data to variables in VD.net and use them.

            I installed the VFP OLE DB data provider.

            Now I need to see a sample piece of code that works that reads a free
            DBF table using a search for a unique character phrase in one field, and
            then gets data from a couple other character fields and a couple of Memo
            Fields. Any help would be appreciated.

            Thanks,

            Michael Erlewine



            *** Sent via Developersdex http://www.developersdex.com ***
            Don't just participate in USENET...get rewarded for it!

            Comment

            • Michael Erlewine

              #7
              Re: VB 6 LOAD form to VB.NET Question

              I am getting BUILD ERRORS like"Type 'Introduction' is not Defined."

              'Introduction is the name of a form I am using.

              The code looks like this:

              Dim f3 As New Introduction()
              F3.ShowDialog()
              f3.dispose()

              Any ideas?


              Thanks,

              Michael Erlewine
              michael@erlewin e.ent


              Comment

              • Paul Clement

                #8
                Re: VB 6 LOAD form to VB.NET Question

                On Fri, 04 Feb 2005 06:17:44 -0800, Michael Erlewine <michael@erlewi ne.net> wrote:

                ¤ I got the Form to load and I figured out how to ADD A FORM to the
                ¤ project. I have another question.
                ¤
                ¤ Much of my work is in FoxPro. All I need is to read a FREE .DBF table,
                ¤ and transfer the data to variables in VD.net and use them.
                ¤
                ¤ I installed the VFP OLE DB data provider.
                ¤
                ¤ Now I need to see a sample piece of code that works that reads a free
                ¤ DBF table using a search for a unique character phrase in one field, and
                ¤ then gets data from a couple other character fields and a couple of Memo
                ¤ Fields. Any help would be appreciated.
                ¤

                See the following:

                Accessing Visual FoxPro Data in Visual Studio .NET



                Paul ~~~ pclement@amerit ech.net
                Microsoft MVP (Visual Basic)

                Comment

                Working...