How to create two circle shape (circle shapes will work as token for 2 players ) in snake and ladder game. I can’t see any control for that ?

Here is what I’ve done and what I want :
I ve created 100 labels and set their Text property 1…..100 respectively . And now I want is that shape will be shown over the label control so what can I do for that(Actually I don’t see any control for that) ?

One more problem I’m facing there is that I decide to add ladder(I don't add picture box for ladder i just display text) on some labels and want to add snake on some others labels.(like on label 10 , 25 ,65, 77 will have text as ladder and saying these follow to 30,45,85,99 label respectively and same procedure for snake label,i.e they take the token down).So, to show these information on the label I need to display these indicator in different color text on label .

Ex:- on label 10,25,65,77 will display their text(i.e. 10,25,65,77 with forecolor =vbblack) . The problem is that on the these label I want to show info in new line (new line in label with forecolor=vbgreen). So how can I have different colored text on the same labels ?

I know I present the problem in complicated way but I hope you understand the problem

Recommended Answers

All 10 Replies

i'll try it.

And waht about label color(2 colors in a label) problem ?

Labels have only one forecolor. You need to use a picture box, rich textbox or create your own cutom control.

i have shape control and one button. On button click event handler , what should i write that a shape will be there over a label.

i wanna see a shpae control over label.

Which version of vb do you use? Also show us the code you have done sofar, otherwise I don't know where to start off.

i use vs2008.
here is my code:

Public Class Form1

    Dim player As String = "Blue"
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim x, y, count As Integer
        Dim varx, vary As Integer 'for positioin(varx=left and vary=top)
        Dim xbool As Boolean = False
        vary = 549
        Dim lbl As Label
        For x = 1 To 10
            For y = 1 To 10
                count += 1
                lbl = New Label
                lbl.Name = "lbl" & count
                lbl.Size = New Size(90, 60)
                lbl.Left = varx
                lbl.Top = vary
                If (xbool = False) Then
                    varx += 91
                    varx -= 91
                End If
                lbl.Text = "LABEL " & count
                lbl.BackColor = Color.MediumTurquoise
                lbl.TextAlign = ContentAlignment.MiddleCenter
                AddHandler lbl.Click, AddressOf lbl_click
            vary -= 61
            'varx = 0
            If (xbool = False) Then
                xbool = True
                varx = 819
                xbool = False
                varx = 0
            End If
        lblPlayer.Text += " " & player
    End Sub
    Private Sub lbl_click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim lbl As Label = DirectCast(sender, Label)
        MsgBox("top=" & lbl.Top & vbNewLine & "Left=" & lbl.Left & vbNewLine & "Name=" & lbl.Name)
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        player = IIf(player = "Blue", "Green", "Blue")
        lblPlayer.Text = "Active Player is " & player
        'OvalShape1.Left = 10
        'OvalShape1.Top = 555
    End Sub
End Class

Here on form load , i create 100 Label(lbl1 to lbl100) dynamically.
And on Button1_click i just want that ovalshape1 should be set over first label(on lbl1).When i try , the ovalshape1 became invisible.

'OvalShape1.Left = 10
'OvalShape1.Top = 555

with this code , i want to set ovalshape1 over label1 manually(i know its position) , but unfortunately this also does not work.

Even i cannot access label(created dynamically).
see this :

 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        player = IIf(player = "Blue", "Green", "Blue")
        lblPlayer.Text = "Active Player is " & player
        OvalShape1.Left = 10
        OvalShape1.Top = 555
        MsgBox(lbl1.text)   'here i cannot access lbl1 which is created dynamically inside form_load
End Sub

Now , delete that older project and thinking to create a new one .
for this , i need an idea about what controls should i use to create 100 square blocks which have text(forecolor=vbblack) from 1 to 100 respectively. And few of them will have different text(in additional to normal text) in different color.

moreever these block should be capable to have tokens over itself. For token(blue token , gray token) i use 2 shape controls(for 2 players).

please give your suggestion ?

O.K. the irst thing I would do is to make a list of what you want to achieve in each step. Once you have done this I would create small test programs and investigate each control to find out that it does what you want it to do. Instead of overlaying controls you can use for example the label or button to load different pictures in which you create in a paint program. Good luck

Be a part of the DaniWeb community

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