Jump to content
  • Advertisement
Sign in to follow this  
AncientHunter

Quick Question: Loading Forms

This topic is 4075 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi everyone, Just a quick question, im making a noughts and crosses (or tic tac toe, or whatever you want to call it) and i am making 3 forms for it: the form for Player-vs-Computer, the form for Player-vs-Player, and the starting screen that gives the player the option of the two. I was told very roughly on how to do this and this is what i have made:
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Form.FromHandle(Application.StartupPath & "E:\Noughts and Crosses\Noughts and Crosses\Form3.vb")
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Form.FromHandle(Application.StartupPath & "E:\Noughts and Crosses\Noughts and Crosses\Form2.vb")
    End Sub
End Class



For those out there with skill in coding you probibaly will see from the code that it complains when i run it. If anyone could help me in this minor problem then it would realy be appreciated.

Share this post


Link to post
Share on other sites
Advertisement
Appending the application path and another absolute path won't work, and FromHandle uses a window handle anyway, not a filename. [smile]

I think what you probably need is something like this:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' We need to create a new instance of the Form3 class.
Dim NewFormToDisplay As Form3 = New Form3()
' Now we have created the instance, we just need to display it:
NewFormToDisplay.Show()
End Sub


I'm not sure why you have two different forms, though. You only need one, and a bit of logic that checks when the other player is about to make a move. If that other player is set as a human they click as normal, otherwise your AI code is run and the piece is placed automatically.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!