i've 9 button(i've set "" to button text) there and all buttons have almost same code as button1 has and here is the code :-

 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If (exitgame = 0) Then
            If (Button1.Text = "") Then
                Label2.Text = "Active Player Name ==>  " & player
                If (player = "X") Then
                    player = "O"
                Else
                    player = "X"
                End If
                Button1.Text = player
                checkfordraw()
            End If
        End If
End Sub

and here is code for checkfordraw()

Public Sub checkfordraw()
        If (exitgame <> 1) Then
            If (Button1.Text <> "" And Button2.Text <> "" And Button3.Text <> "" And Button4.Text <> "" And Button5.Text <> "" And Button6.Text <> "" And Button7.Text <> "" And Button8.Text And Button9.Text <> "") Then
                If (MsgBox("No more places " & vbNewLine & "Game Draw " & vbNewLine & "would you like to play new game ?", MsgBoxStyle.OkCancel) = MsgBoxResult.Ok) Then
                    Button10.PerformClick()
                End If
            End If
        End If
End Sub

when i first click on on any button(except button10) it gives an error saying "InvalidCastException Unhandled" and "Conversion from string "" to type 'Boolean' is not valid".Error occurs at line no three in checkdraw() procedure(i.e second if condition).

I guess Button8.Text doesnt have a condition, somewhat like.. Button8.Text<> ""

i didn't notice that.
thanks for pointing it out.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.