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:
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.
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