The McLeodGaming forums were permanently closed on April 30th, 2020. You are currently viewing a read-only archive.
View unanswered posts | View active topics It is currently Fri May 15, 2020 9:26 am



 [ 5 posts ] 
[VB.NET] Dynamically created events 
Author Message
User avatar

Joined: Sat Aug 23, 2008 3:10 am
Posts: 2601
Location: Australia - Sydney
Gender: Male
Currently Playing: Ninja Gaiden III
I'm writing a piece of code in vb.net.

There's a scrabble board that's 15x15 picture boxes.

I need to have an on-click even for each one (so it will be Handles pbo11.click, pbo21.click etc.), each on-click event will have the same algorithm.

How would you recommend doing this?

_________________
Image


Fri Jul 08, 2011 3:07 am
WWW
User avatar

Joined: Sat Aug 16, 2008 8:38 am
Posts: 6670
Location: Darkest Antartica
Country: Pakistan (pk)
Gender: Male
Skype: Thaiberium
Currently Playing: The Game
I dunno, how'd you design the board spaces?

_________________
Image


Fri Jul 08, 2011 4:33 am
User avatar

Joined: Sat Aug 23, 2008 3:10 am
Posts: 2601
Location: Australia - Sydney
Gender: Male
Currently Playing: Ninja Gaiden III
Create a new picture box, give it a size, location, name, tag and image and put it down.

2 FOR loops ensured that there are now 225 of them in a square shape (Scrabble board shape)

If that's not the answer to your question, then I don't know what you're asking.

_________________
Image


Fri Jul 08, 2011 7:03 am
WWW
User avatar

Joined: Sat Aug 16, 2008 8:38 am
Posts: 6670
Location: Darkest Antartica
Country: Pakistan (pk)
Gender: Male
Skype: Thaiberium
Currently Playing: The Game
Oh wait I'm approaching this all wrong. Stupid me.

Doesn't VB have a library that records mouse events or something? It should have one, if any assumptions I have of VB being any where near similar to C and its derivatives. Thus when you press a mouse button, it checks where and you just have to modify the appropriate image box.

As for the design, ignore it. I was just curious. I would have tried using a two-dimensional array of classes.

_________________
Image


Fri Jul 08, 2011 7:37 am
User avatar

Joined: Mon Aug 18, 2008 7:58 pm
Posts: 1093
Gender: Male
I'd help using some of my upcoming game's code but it depends. Maybe ONE giant PicBox and a few smaller ones below each seperate. The big one requires a 2-D array if u wanna display graphics.
Double click a PicBox to activate a "click" event for it
Dim Canvas As Graphics
Dim Board As Bitmap

TIMER1 (to draw the pics on the board)
Board = New Bitmap() 'inside goes ur board's dimmensions. Maybe try 1000,1000?
Canvas = Graphics.FromImage(Board)

End Sub '(TIMER)

Above "Windows Generated Code" is the General Declarations
Const A = Player 1
Dim A As Bitmap = Bitmap.FromFile("TabletA.png")
Dim Map(,) As Integer = _
{{0,0,0,0,0,0,0,0,0,0}, _
'Copy 10 times
in Timer1:
For x As Integer = 0 To 9
For y As Integer = 0 To 9
(SAMPLE):
'If Map(x,y) = 1 and turn = A Then
Canvas.DrawImage(TabletA, x *100, y*100)
Next
Next
PicBox1.Image = Board

For this you can say:
PicBox_Click
If PicBox2.Image = TbA Then
Map(5,6) = 1
PicBox2.Image = ""

Questions? PM me.

_________________
ImageImage

Image
Current Demo: None! Go check it out!


Wed Jul 27, 2011 9:40 am
Display posts from previous:  Sort by  
 [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software for PTF.