3 Replies - 714 Views - Last Post: 17 December 2007 - 11:53 AM Rate Topic: -----

#1 koolaroo  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 10-December 07

help vb7

Posted 17 December 2007 - 08:58 AM

can someone give me the code to make a button Switch between form1 and form2.
Is This A Good Question/Topic? 0
  • +

Replies To: help vb7

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4361
  • View blog
  • Posts: 12,180
  • Joined: 18-April 07

Re: help vb7

Posted 17 December 2007 - 10:30 AM

Can you clarify what you mean by switch between? Do you mean have a button on one form launch another form? Or when you click it, it hides the current form and shows another form? Any clarification would help. Thanks! :)
Was This Post Helpful? 0
  • +
  • -

#3 koolaroo  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 10-December 07

Re: help vb7

Posted 17 December 2007 - 11:47 AM

View PostMartyr2, on 17 Dec, 2007 - 10:30 AM, said:

Can you clarify what you mean by switch between? Do you mean have a button on one form launch another form? Or when you click it, it hides the current form and shows another form? Any clarification would help. Thanks! :)

when you click on it it hides the curren form and shows another form
Was This Post Helpful? 0
  • +
  • -

#4 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4361
  • View blog
  • Posts: 12,180
  • Joined: 18-April 07

Re: help vb7

Posted 17 December 2007 - 11:53 AM

Simple enough...

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

		' Declare a variable of the other form's type. In this case Form2.
		Dim myotherform As New Form2

		' Show that form
		myotherform.Show()

		' Hide the current form.
		Me.Hide()
End Sub



As you can see we declare a variable of type form2, we call its show method to show the form, then we hide the current form. The result is that we change forms.

Hope that is what you were looking for. Enjoy! :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1