Sub Main Ends so does the application

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

    Sub Main Ends so does the application

    Admittedly, I am new to VB.NET

    I have some real simple code that I am trying to run in VB.NET

    Friend Module xxx
    Friend F1 As Form1
    -----------------

    Public Sub Main()

    F1 = New Form1

    Form1.Show()

    End Sub

    All I am trying to do is show the form. However, at the End Sub statement
    the form closes..... I am confused. Any ideas?


  • iwdu15

    #2
    RE: Sub Main Ends so does the application

    if you want to use forms, create a Windows Application, at the end of the
    sub, the program terminates, so if you want to use forms (usually) you want
    to use a Windows Application
    --
    -iwdu15

    Comment

    • Jim Wooley

      #3
      Re: Sub Main Ends so does the application

      Use Application.Run (Form1) instead of Form1.Show()

      Jim Wooley

      Admittedly, I am new to VB.NET
      >
      I have some real simple code that I am trying to run in VB.NET
      >
      Friend Module xxx
      Friend F1 As Form1
      -----------------
      Public Sub Main()
      >
      F1 = New Form1
      >
      Form1.Show()
      >
      End Sub
      >
      All I am trying to do is show the form. However, at the End Sub
      statement the form closes..... I am confused. Any ideas?
      >

      Comment

      • GhostInAK

        #4
        Re: Sub Main Ends so does the application

        Hello Jim,

        Actually using the OP's original code fragment it would be Application.Run (F1)..

        or, optionally Application.Run (new Form1)


        -Boo
        Use Application.Run (Form1) instead of Form1.Show()
        >
        Jim Wooley
        http://devauthority.com/blogs/jwooley/default.aspx
        >Admittedly, I am new to VB.NET
        >>
        >I have some real simple code that I am trying to run in VB.NET
        >>
        >Friend Module xxx
        >Friend F1 As Form1
        >-----------------
        >Public Sub Main()
        >F1 = New Form1
        >>
        >Form1.Show()
        >>
        >End Sub
        >>
        >All I am trying to do is show the form. However, at the End Sub
        >statement the form closes..... I am confused. Any ideas?
        >>

        Comment

        • Cor Ligthert [MVP]

          #5
          Re: Sub Main Ends so does the application

          RRowe,

          Just as addition,

          Did you know that a VBNet mainform has an inbuild submain with an
          application run as long as you have not done that yourself.

          Cor

          "rrowe" <rr0we@hotmail. comschreef in bericht
          news:%23l3lWF1r GHA.3380@TK2MSF TNGP04.phx.gbl. ..
          Admittedly, I am new to VB.NET
          >
          I have some real simple code that I am trying to run in VB.NET
          >
          Friend Module xxx
          Friend F1 As Form1
          -----------------
          >
          Public Sub Main()
          >
          F1 = New Form1
          >
          Form1.Show()
          >
          End Sub
          >
          All I am trying to do is show the form. However, at the End Sub
          statement
          the form closes..... I am confused. Any ideas?
          >

          Comment

          • zacks@construction-imaging.com

            #6
            Re: Sub Main Ends so does the application


            Cor Ligthert [MVP] wrote:
            RRowe,
            >
            Just as addition,
            >
            Did you know that a VBNet mainform has an inbuild submain with an
            application run as long as you have not done that yourself.
            >
            Cor
            But if you want to do things like enable visual styles, read a config
            file or manually display a splash screen, you will need to make it.
            >
            "rrowe" <rr0we@hotmail. comschreef in bericht
            news:%23l3lWF1r GHA.3380@TK2MSF TNGP04.phx.gbl. ..
            Admittedly, I am new to VB.NET

            I have some real simple code that I am trying to run in VB.NET

            Friend Module xxx
            Friend F1 As Form1
            -----------------

            Public Sub Main()

            F1 = New Form1

            Form1.Show()

            End Sub

            All I am trying to do is show the form. However, at the End Sub
            statement
            the form closes..... I am confused. Any ideas?

            Comment

            • Cor Ligthert [MVP]

              #7
              Re: Sub Main Ends so does the application

              But if you want to do things like enable visual styles, read a config
              file or manually display a splash screen, you will need to make it.
              >
              Or maybe as showed on this page?



              Cor

              <zacks@construc tion-imaging.comschr eef in bericht
              news:1153832848 .890681.129930@ m73g2000cwd.goo glegroups.com.. .
              >
              Cor Ligthert [MVP] wrote:
              >RRowe,
              >>
              >Just as addition,
              >>
              >Did you know that a VBNet mainform has an inbuild submain with an
              >application run as long as you have not done that yourself.
              >>
              >Cor
              >
              But if you want to do things like enable visual styles, read a config
              file or manually display a splash screen, you will need to make it.
              >
              >>
              >"rrowe" <rr0we@hotmail. comschreef in bericht
              >news:%23l3lWF1 rGHA.3380@TK2MS FTNGP04.phx.gbl ...
              Admittedly, I am new to VB.NET
              >
              I have some real simple code that I am trying to run in VB.NET
              >
              Friend Module xxx
              Friend F1 As Form1
              -----------------
              >
              Public Sub Main()
              >
              F1 = New Form1
              >
              Form1.Show()
              >
              End Sub
              >
              All I am trying to do is show the form. However, at the End Sub
              statement
              the form closes..... I am confused. Any ideas?
              >
              >

              Comment

              Working...