6 Replies - 10943 Views - Last Post: 20 November 2008 - 10:47 AM Rate Topic: -----

#1 STFCBarsby  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 29-September 08

Going back to previous form

Posted 17 November 2008 - 03:33 PM

Hi guys,

Me and a friend at college was trying to figure this out, but it confused the hell out of us and we still can't figure it out after googling for ages.

Basically, we want to have a button take them back to the form they were last using. We have an "exit" button, which takes them to form7, so we know that we need:

Form7.show
		 Me.hide


Now, that will be used on any forms with the exit button and will always go to Form 7. Form 7 will have a button called "Back to Game", which we want to take them back to the form they clicked the "Exit" button on, we've tried things such as the Return command, GoBack and so forth but haven't got ourselves anywhere.

Any idea on how to go about this?

Many Thanks,
Chris.

Is This A Good Question/Topic? 0
  • +

Replies To: Going back to previous form

#2 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2270
  • View blog
  • Posts: 9,496
  • Joined: 29-May 08

Re: Going back to previous form

Posted 17 November 2008 - 04:23 PM

Create a global variable Dim ExitedForm as Form
In the exit button
ExitedForm=Me
Form7.Show
me.hide


In the "Back To Game" Button
ExitedForm.show



It would useful if you rename Form7 to something more descriptive like MenuForm

This post has been edited by AdamSpeight2008: 17 November 2008 - 04:23 PM

Was This Post Helpful? 0
  • +
  • -

#3 STFCBarsby  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 29-September 08

Re: Going back to previous form

Posted 18 November 2008 - 12:12 PM

Adam,

I done that but it didn't seem to work, done everything but take us back to the form we wanted it to.

Any other ideas?
Was This Post Helpful? 0
  • +
  • -

#4 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1642
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Going back to previous form

Posted 18 November 2008 - 12:22 PM

Along the lines of Adam's theory (his wont work because it's global to that form only), try creating a variable in the Settings for the application (that is of type Form), then when the exit button is clicked set the value

'Set the value
My.Settings.ExitedForm = Me

'Save the settings
My.Settings.Save()

'Show Form7
Form7.Show

'Hide this form
Me.Hide



Then when they click "Back to game" use this

Dim showForm As Form = My.Settings.ExitedForm
showForm.Show
Me.Hide



Using the global application settings (My.Settings) should give you a value that's accessible from any form in your application.

Hope that helps :)
Was This Post Helpful? 0
  • +
  • -

#5 magicmonkey  Icon User is offline

  • D.I.C Regular

Reputation: 106
  • View blog
  • Posts: 484
  • Joined: 12-September 08

Re: Going back to previous form

Posted 18 November 2008 - 02:01 PM

Taking PsychoCoder's idea, what about adding a static property to the mainmenu form (form7),

Public Shared ExitedForm as Form

Then you can set it with Form7.ExitedForm = Me
Was This Post Helpful? 0
  • +
  • -

#6 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2270
  • View blog
  • Posts: 9,496
  • Joined: 29-May 08

Re: Going back to previous form

Posted 18 November 2008 - 09:24 PM

View PostPsychoCoder, on 18 Nov, 2008 - 06:22 PM, said:

Along the lines of Adam's theory (his wont work because it's global to that form only), try creating a variable in the Settings for the application (that is of type Form), then when the exit button is clicked set the value


I tend to place all me Global Variables in a separate module called strangely Globals.
Was This Post Helpful? 0
  • +
  • -

#7 STFCBarsby  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 29-September 08

Re: Going back to previous form

Posted 20 November 2008 - 10:47 AM

PsychoCoder, couldn't get yours to work either, but no worries we've decided to scrap this idea.

Thanks guys.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1