• ### Popular Now

• 13
• 18
• 19
• 27
• 10

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

## 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 on other sites
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.