School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!
You're Browsing As A Guest! Register Now...
Become an Expert!

Join 353,888 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 3,180 people online right now.Registration is fast and FREE... Join Now!



Visual Basic 2008- Minesweeper

52 Weeks of Code Challenge: WPF

Week #10 of the 52 Weeks of Code Challenge is WPF. If you're a .NET programmer, you should give it a shot. Click Here!
Page 1 of 1

Visual Basic 2008- Minesweeper trying to assign dynamically created buttons to an 2D array Rate Topic: -----

#1 belscher82  Icon User is offline

  • New D.I.C Head
  • Pip

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 19-March 09


Dream Kudos: 0

Post icon  Posted 22 March 2009 - 10:01 AM

I'm trying to assign coordinates to the buttons I dynamically placed on the board, so that I can use those coordinates to place bombs, numbers etc
I tried a collection and an array but doesn't seem to work .

Attached is a picture of the game board, I have literally spent days on this.

Any assistance is greatly appreciated





Public Class Form1
	Public tpos As Integer = 100
	Public lpos As Integer = 25
	Public counter As Integer

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

		Call myform()
		Do Until counter = 8
			counter += 1
			Call btnrow()
			lpos += 25
			tpos -= 200
		Loop
	End Sub
	Private Sub myform()
		Me.Height = 350
		Me.Width = 250
		Me.Label1.Location = New System.Drawing.Point(185, 50)
		Me.Label2.Location = New System.Drawing.Point(25, 50)
		Me.smilebtn.Size = New Size(25, 25)
		Me.smilebtn.Location = New System.Drawing.Point(112, 50)
	End Sub
	Private Sub btnrow()

		Dim mycollection As New Collection
		Dim myarray(0 To 8, 0 To 8) As String
		Dim counter As Integer
		Do Until counter = 8
			counter += 1
			Dim button1 As New Button
			With button1
				.BackColor = Color.Gray
				.Size = New Size(25, 25)
				.Top = tpos
				.Left = lpos
				.Name = (tpos & "," & lpos)
				'button1.Location = New Point(tpos, lpos)
				Me.Controls.Add(button1)
				mycollection.Add(button1.Name)
				myarray(0, 1) = button1.Name
			End With
			tpos += 25

		Loop
		Dim mylastname As String


		mylastname = mycollection.Item(1)

		MsgBox(mylastname)
	End Sub

	
	Private Sub NewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewToolStripMenuItem.Click

	End Sub

	Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
		Me.Close()
	End Sub

	Private Sub HelpToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HelpToolStripMenuItem.Click
		MsgBox("I need !@#$ Help")
	End Sub

	Private Sub BeginnerToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BeginnerToolStripMenuItem.Click
		BeginnerToolStripMenuItem.Checked = True
		IntermediateToolStripMenuItem.Checked = False
		ExpertToolStripMenuItem.Checked = False
	End Sub

	Private Sub IntermediateToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles IntermediateToolStripMenuItem.Click
		BeginnerToolStripMenuItem.Checked = False
		IntermediateToolStripMenuItem.Checked = True
		ExpertToolStripMenuItem.Checked = False
	End Sub

	Private Sub ExpertToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExpertToolStripMenuItem.Click
		BeginnerToolStripMenuItem.Checked = False
		IntermediateToolStripMenuItem.Checked = False
		ExpertToolStripMenuItem.Checked = True
	End Sub

	Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click



	End Sub

	Private Sub smilebtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles smilebtn.Click

	End Sub
End Class


Was This Post Helpful? 0
  • +
  • -


#2 JackOfAllTrades  Icon User is offline

  • Mayor of Simpleton
  • Icon

Reputation: 716
  • View blog
  • Posts: 7,936
  • Joined: 23-August 08


Dream Kudos: 50

Expert In: Being annoyed with lazy people.

Re: Visual Basic 2008- Minesweeper

Posted 22 March 2009 - 10:42 AM

Can you please be more specific than it doesn't work? What does it do versus what you expect it to do?
Was This Post Helpful? 0
  • +
  • -

#3 belscher82  Icon User is offline

  • New D.I.C Head
  • Pip

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 19-March 09


Dream Kudos: 0

Re: Visual Basic 2008- Minesweeper

Posted 22 March 2009 - 10:51 AM

Sorry,

I tried to create an 2 D array that would assign values to the buttons I dynamically created. I guess I'm just not sure if i worked is there a way to determine if the first button1.name got assigned to the first array cordinate (0,1). ie can I CREATE A MESSAGE BOX OR STATEMENT TO TEST IT?


View PostJackOfAllTrades, on 22 Mar, 2009 - 10:42 AM, said:

Can you please be more specific than it doesn't work? What does it do versus what you expect it to do?

Was This Post Helpful? 0
  • +
  • -

#4 vb5prgrmr  Icon User is offline

  • D.I.C Addict
  • PipPipPipPip

Reputation: 57
  • View blog
  • Posts: 725
  • Joined: 21-March 09


Dream Kudos: 0

Re: Visual Basic 2008- Minesweeper

Posted 23 March 2009 - 12:13 AM

Okay, I know a moderator has see this thread but why has it not been moved to the proper forum? This is the "classic" area for us old farts who begrudgingly hang on to vb6 and if you look to the left (at or near the top of this page) you will see a vb.net forum.
Was This Post Helpful? 0
  • +
  • -

#5 JackOfAllTrades  Icon User is offline

  • Mayor of Simpleton
  • Icon

Reputation: 716
  • View blog
  • Posts: 7,936
  • Joined: 23-August 08


Dream Kudos: 50

Expert In: Being annoyed with lazy people.

Re: Visual Basic 2008- Minesweeper

Posted 23 March 2009 - 07:07 AM

Good point, vb5...moving to VB.NET.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1


Fast Reply

  

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month