Click here to Skip to main content
15,914,594 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All,

I am writing a minesweeper in vb 2010 Express. Yet, I have add some rules for the mine setting.
I hope there will be a route that can let the user from one side to the other side.
Also, "heart" will be give depends on the level of the difficulties that the user choose to play in order to avoid they "luckily" press the mine in the first step.

I would like to ask whether should I use 2D array or should I draw a map in txt and connect to the button/the picture box?
If I need to use a map for the mine setting, can you tell me the way to connect the txt file to vb?

I don't require you to give me all the code as I think it is better for me to do it once by my hand rather copying others work. But at least give me the step in connecting the txt file to vb. You may use some code for your explanation (depends on your own).

Also, I get some problem in the connection with the access database.

I use the data connection to connect the access file as made a data set.
However, when I am debugging, the system said "InvalidOperationExpection is unhandled: The connection was not closed. The connection's current state is open. " Then, I just close the connection and try it once more but it stills show the same warning message.
What can I do in order to fix this problem?

I have opened a Module for setting the public path and it is shown as follow:

VB
Module ModuleTorpedosweepers

    Public con As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\ICT\SBA\Torpedosweepers3\Torpedosweepers1\bin\Debug\torpedosweepers1.mdb")

End Module


And here are the code for the Login form.

VB
Public Class frmLogin
    Public Sub Login_Data()
        con.Open()

        Dim dt As New DataTable("tblUser")
        Dim rs As New OleDb.OleDbDataAdapter("Select UserID, Passwords from tblUser where UserID ='" & txtUserID.Text & "'and passwords ='" & txtPassword.Text & "'", con)
        rs.Fill(dt)
        DataGridView1.DataSource = dt


        Label1.Text = dt.Rows.Count

        con.Close()

        If Val(Label1.Text) > 0 Then
            MsgBox("Welcome!")
            txtUserID.Clear()
            txtPassword.Clear()
            Me.Hide()
            frmMenu.Show()
        Else
            MsgBox("Inavlid User ID and/or passwords.")
        End If
    End Sub

    Public Sub Display_Data()
        con.Open()

        Dim dt As New DataTable("tblUser")
        Dim rs As New OleDb.OleDbDataAdapter("Select UserID, Passwords from tblUser", con)
          rs.Fill(dt)
        DataGridView1.DataSource = dt
        DataGridView1.Refresh()

        Label1.Text = dt.Rows.Count

        rs.Dispose()
    End Sub

    Private Sub btnSignUp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSignUp.Click
        Me.Hide()
        frmCreateAC.Show()
    End Sub

    Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
        Login_Data()
    End Sub

    Private Sub frmLogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Display_Data()
    End Sub

End Class


At last, thank you all for viewing this post and answering my question. :")


Regards,
Patricia
Posted
Updated 30-Sep-15 16:41pm
v3
Comments
Leo Chapiro 30-Sep-15 8:07am    
Take a look: MineSweeper VB.Net: The following VB.NET project contains the source code and VB.NET examples used for MineSweeper VB.Net. Minesweeper game example.
CHill60 30-Sep-15 8:14am    
I would post that as a solution TBH
Leo Chapiro 30-Sep-15 8:41am    
Done :)
Patricia Chang 30-Sep-15 8:33am    
Thanks for your sharing! :))
Leo Chapiro 30-Sep-15 8:41am    
You are welcome, HTH!

1 solution

Take a look: MineSweeper VB.Net: The following VB.NET project contains the source code and VB.NET examples used for MineSweeper VB.Net. Minesweeper game example.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900