8 Replies - 539 Views - Last Post: 05 March 2009 - 12:48 PM Rate Topic: -----

#1 Darkangler  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 49
  • Joined: 09-September 08

detecting victory in separate Form

Posted 24 February 2009 - 07:23 PM

In a project I'm working on, I have 3 separate mazes, a Splash Screen, and a Module for my global variable(gWin, to detect wins on the mazes). When you finish a maze, I'd like to get it so that it does not allow you to go back and redo a maze, to prevent cheating as I want a final screen to appear when they complete all 3 of the mazes. Is there a way that I can make a variable or something to be able to check if a maze was already completed then cause that maze to have it's .Enabled property set to false? I would post code to start this, but I'm stuck before beginning this aspect of the project. Any help would be greatly appreciated.

Is This A Good Question/Topic? 0
  • +

Replies To: detecting victory in separate Form

#2 Wrecks  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 71
  • Joined: 24-February 09

Re: detecting victory in separate Form

Posted 24 February 2009 - 10:02 PM

Make your variables in each form public, then the code in any other form can access them.
Was This Post Helpful? 0
  • +
  • -

#3 Darkangler  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 49
  • Joined: 09-September 08

Re: detecting victory in separate Form

Posted 27 February 2009 - 02:04 PM

So make like global variables in them to determine victory while in another maze? I'm kinda confused with what you mean by that.. Even if they are public, how would that be detected in the other maze? variables don't have a .show or anything. I'm still somewhat new at all this, so I must ask some "stupid" questions.
Was This Post Helpful? 0
  • +
  • -

#4 Wrecks  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 71
  • Joined: 24-February 09

Re: detecting victory in separate Form

Posted 28 February 2009 - 10:47 PM

Say you had three Classes like this:
Public Class Form1
	Public Variable1 As String

	Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

	End Sub
End Class

Public Class Form2
	Public Variable2 As String

	Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

	End Sub
End Class

Public Class Form3
	Public Variable3 As String

	Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

	End Sub
End Class


You could access Variable1 in Form1 from any other form in this manner:

Form1.Variable1

Likewise, you could access Variable2 in Form2 from any other form in this manner:

Form2.Variable2

I'll bet you can figure out from there how to access Variable3 in Form3 now...
Was This Post Helpful? 1
  • +
  • -

#5 Darkangler  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 49
  • Joined: 09-September 08

Re: detecting victory in separate Form

Posted 03 March 2009 - 02:10 PM

So what you are telling me is that I need to put a Public variable into each form, then have it so that when the user wins, that variable is set to let's say 1?

 If picPlayer.left >= 100 And picPlayer.Top >= 200 And picPlayer.Bottom <= 230 And picPlayer.Right <= 130 Then
	 Variable1 += 1
 End If


Then when the user moves to the next maze, since that first variable was public, I would be able to put a code in such as...

 If Variable1 = 1 Then Maze1.Enabled = False 


And so on and so on?
Was This Post Helpful? 0
  • +
  • -

#6 Wrecks  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 71
  • Joined: 24-February 09

Re: detecting victory in separate Form

Posted 03 March 2009 - 02:23 PM

I haven't seen any of your code, so I can't tell you if it will definately work or not, but it sounds reasonable.

By the way you need to change:

Variable1 += 1

To:

Variable1 = 1

...or you could get an unexpected result.
Was This Post Helpful? 0
  • +
  • -

#7 Darkangler  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 49
  • Joined: 09-September 08

Re: detecting victory in separate Form

Posted 03 March 2009 - 02:33 PM

Alright, I'll give it a shot, thanks much =)
Was This Post Helpful? 0
  • +
  • -

#8 jase81  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 120
  • Joined: 02-March 09

Re: detecting victory in separate Form

Posted 03 March 2009 - 05:02 PM

Add to your global module

Module modGlobal

	Public gWin as ....
	Public Maze1_complete as boolean = false
	Public Maze2_complete as boolean = false
	Public Maze3_complete as boolean = false

End Module



In form_load add: If maze1_complete = true then don't open form
When you win set maze1_complete = true, can be done from any form
Was This Post Helpful? 1
  • +
  • -

#9 Darkangler  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 49
  • Joined: 09-September 08

Re: detecting victory in separate Form

Posted 05 March 2009 - 12:48 PM

View Postjase81, on 3 Mar, 2009 - 04:02 PM, said:

Add to your global module

Module modGlobal

	Public gWin as ....
	Public Maze1_complete as boolean = false
	Public Maze2_complete as boolean = false
	Public Maze3_complete as boolean = false

End Module



In form_load add: If maze1_complete = true then don't open form
When you win set maze1_complete = true, can be done from any form


That worked wonderfully, thank you so much. I've been so preoccupied with working with variables that I forgot about booleans.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1