Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. show form2 ........

show form2 ........

Scheduled Pinned Locked Moved Visual Basic
question
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Ritesh1234
    wrote on last edited by
    #1

    Hi Guru's, How can i achieve this...............:confused: There is a button on form1. On button clicking need to show form2 and close the form1(not to hide the form1) Regards, Ritesh

    C A 2 Replies Last reply
    0
    • R Ritesh1234

      Hi Guru's, How can i achieve this...............:confused: There is a button on form1. On button clicking need to show form2 and close the form1(not to hide the form1) Regards, Ritesh

      C Offline
      C Offline
      Charlie Williams
      wrote on last edited by
      #2

      Well, the short answer is

      form2.Show()
      Me.Close()

      However, in reality it's not quite that simple. When you show your first form with Application.Run(New Form1()), the lifetime of the application is tied to the lifetime of your form. There's an article[^] by Marc Clifton on this site that explains how to switch top-level forms using a custom application context. Another approach is to start the application with an object that knows how to launch and close the forms in your application. To start with, it would show the initial "view" of your application (Form1) and, upon request, switch to a different "view", which could be closing form1 and opening form2 or opening forms 2 or three and closing form1 conditionally or whatever. The second approach is infinitely more flexible, but it also requires more work to implement. Charlie if(!curlies){ return; }

      1 Reply Last reply
      0
      • R Ritesh1234

        Hi Guru's, How can i achieve this...............:confused: There is a button on form1. On button clicking need to show form2 and close the form1(not to hide the form1) Regards, Ritesh

        A Offline
        A Offline
        aprx
        wrote on last edited by
        #3

        in the Form1 , write this, attached to the Command1 button : Sub Command1_Click() Form2.Show End Sub in the Form2, write this : Private Sub Form_Load() Unload Form1 End Sub aprx

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups