Card game

attempt at a card game

Page 1 of 1

7 Replies - 1599 Views - Last Post: 05 May 2010 - 06:34 PM Rate Topic: -----

#1 JonA40  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 04-May 10

Card game

Posted 05 May 2010 - 11:22 AM

Im trying to make a 5 card draw game , here is the code i have so far,but its not working the right way ,
any help would be great,thanks
Im not sure if I should be using an ifthen or an ifelse for the cards.
I have a pic file for the cards for the pictureboxes,

Public Class Form1

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

    Private Sub PictureBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
        If PictureBox2.Visible = True Then BringToFront()
        If PictureBox1.Visible = True Then SendToBack()

    End Sub

    Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
        If PictureBox1.Visible = True Then BringToFront()
        If PictureBox2.Visible = True Then SendToBack()



    End Sub
    Private Sub PictureBox3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
        If PictureBox1.Visible = True Then BringToFront()
        If PictureBox2.Visible = True Then SendToBack()



    End Sub
    Private Sub PictureBox4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
        If PictureBox1.Visible = True Then BringToFront()
        If PictureBox2.Visible = True Then SendToBack()



    End Sub
    Private Sub PictureBox5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
        If PictureBox1.Visible = True Then BringToFront()
        If PictureBox2.Visible = True Then SendToBack()



    End Sub
    Private Sub PictureBox6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
        If PictureBox1.Visible = True Then BringToFront()
        If PictureBox2.Visible = True Then SendToBack()



    End Sub

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        Label1.Text = CStr(Int(Rnd() * 53 + 1))
        Label2.Text = CStr(Int(Rnd() * 53 + 1))
        Label3.Text = CStr(Int(Rnd() * 53 + 1))
        Label4.Text = CStr(Int(Rnd() * 53 + 1))
        Label5.Text = CStr(Int(Rnd() * 53 + 1))
        Do
            If (Label1.Text = "1") Then PictureBox1.Visible = True
            If PictureBox1.Visible = True Then BringToFront()
            If (Label1.Text = "2") Then PictureBox2.Visible = True
            If PictureBox2.Visible = True Then BringToFront()
            If (Label1.Text = "3") Then PictureBox3.Visible = True
            If PictureBox3.Visible = True Then BringToFront()
            If (Label1.Text = "4") Then PictureBox4.Visible = True
            If PictureBox4.Visible = True Then BringToFront()
            If (Label1.Text = "5") Then PictureBox5.Visible = True
            If PictureBox5.Visible = True Then BringToFront()
            If (Label1.Text = "6") Then PictureBox6.Visible = True
            If PictureBox6.Visible = True Then BringToFront()
            If (Label1.Text = "7") Then PictureBox7.Visible = True
            If PictureBox7.Visible = True Then BringToFront()
            If (Label1.Text = "8") Then PictureBox8.Visible = True
            If PictureBox8.Visible = True Then BringToFront()
            If (Label1.Text = "9") Then PictureBox9.Visible = True
            If PictureBox9.Visible = True Then BringToFront()
            If (Label1.Text = "10") Then PictureBox10.Visible = True
            If PictureBox10.Visible = True Then BringToFront()
            If (Label1.Text = "11") Then PictureBox11.Visible = True
            If PictureBox11.Visible = True Then BringToFront()
            If (Label1.Text = "12") Then PictureBox12.Visible = True
            If PictureBox12.Visible = True Then BringToFront()
            If (Label1.Text = "13") Then PictureBox13.Visible = True
            If PictureBox13.Visible = True Then BringToFront()
            If (Label1.Text = "14") Then PictureBox14.Visible = True
            If PictureBox14.Visible = True Then BringToFront()
            If (Label1.Text = "15") Then PictureBox15.Visible = True
            If PictureBox15.Visible = True Then BringToFront()
            If (Label1.Text = "16") Then PictureBox16.Visible = True
            If PictureBox16.Visible = True Then BringToFront()
            If (Label1.Text = "17") Then PictureBox17.Visible = True
            If PictureBox17.Visible = True Then BringToFront()
            If (Label1.Text = "18") Then PictureBox18.Visible = True
            If PictureBox18.Visible = True Then BringToFront()
            If (Label1.Text = "19") Then PictureBox19.Visible = True
            If PictureBox19.Visible = True Then BringToFront()
            If (Label1.Text = "20") Then PictureBox20.Visible = True
            If PictureBox20.Visible = True Then BringToFront()
            If (Label1.Text = "21") Then PictureBox21.Visible = True
            If PictureBox21.Visible = True Then BringToFront()
            If (Label1.Text = "22") Then PictureBox22.Visible = True
            If PictureBox22.Visible = True Then BringToFront()
            If (Label1.Text = "23") Then PictureBox23.Visible = True
            If PictureBox23.Visible = True Then BringToFront()
            If (Label1.Text = "24") Then PictureBox24.Visible = True
            If PictureBox24.Visible = True Then BringToFront()
            If (Label1.Text = "25") Then PictureBox25.Visible = True
            If PictureBox25.Visible = True Then BringToFront()
            If (Label1.Text = "26") Then PictureBox26.Visible = True
            If PictureBox26.Visible = True Then BringToFront()
            If (Label1.Text = "27") Then PictureBox27.Visible = True
            If PictureBox27.Visible = True Then BringToFront()
            If (Label1.Text = "28") Then PictureBox28.Visible = True
            If PictureBox28.Visible = True Then BringToFront()
            If (Label1.Text = "29") Then PictureBox29.Visible = True
            If PictureBox29.Visible = True Then BringToFront()
            If (Label1.Text = "30") Then PictureBox30.Visible = True
            If PictureBox30.Visible = True Then BringToFront()
            If (Label1.Text = "31") Then PictureBox31.Visible = True
            If PictureBox31.Visible = True Then BringToFront()
            If (Label1.Text = "32") Then PictureBox32.Visible = True
            If PictureBox32.Visible = True Then BringToFront()
            If (Label1.Text = "33") Then PictureBox33.Visible = True
            If PictureBox33.Visible = True Then BringToFront()
            If (Label1.Text = "34") Then PictureBox34.Visible = True
            If PictureBox34.Visible = True Then BringToFront()
            If (Label1.Text = "35") Then PictureBox35.Visible = True
            If PictureBox35.Visible = True Then BringToFront()
            If (Label1.Text = "36") Then PictureBox36.Visible = True
            If PictureBox36.Visible = True Then BringToFront()
            If (Label1.Text = "37") Then PictureBox37.Visible = True
            If PictureBox37.Visible = True Then BringToFront()
            If (Label1.Text = "38") Then PictureBox38.Visible = True
            If PictureBox38.Visible = True Then BringToFront()
            If (Label1.Text = "39") Then PictureBox39.Visible = True
            If PictureBox39.Visible = True Then BringToFront()
            If (Label1.Text = "40") Then PictureBox40.Visible = True
            If PictureBox40.Visible = True Then BringToFront()
            If (Label1.Text = "41") Then PictureBox41.Visible = True
            If PictureBox41.Visible = True Then BringToFront()
            If (Label1.Text = "42") Then PictureBox42.Visible = True
            If PictureBox42.Visible = True Then BringToFront()
            If (Label1.Text = "43") Then PictureBox43.Visible = True
            If PictureBox43.Visible = True Then BringToFront()
            If (Label1.Text = "44") Then PictureBox44.Visible = True
            If PictureBox44.Visible = True Then BringToFront()
            If (Label1.Text = "45") Then PictureBox45.Visible = True
            If PictureBox45.Visible = True Then BringToFront()
            If (Label1.Text = "46") Then PictureBox46.Visible = True
            If PictureBox46.Visible = True Then BringToFront()
            If (Label1.Text = "47") Then PictureBox47.Visible = True
            If PictureBox47.Visible = True Then BringToFront()
            If (Label1.Text = "48") Then PictureBox48.Visible = True
            If PictureBox48.Visible = True Then BringToFront()
            If (Label1.Text = "49") Then PictureBox49.Visible = True
            If PictureBox49.Visible = True Then BringToFront()
            If (Label1.Text = "50") Then PictureBox50.Visible = True
            If PictureBox50.Visible = True Then BringToFront()
            If (Label1.Text = "51") Then PictureBox51.Visible = True
            If PictureBox51.Visible = True Then BringToFront()
            If (Label1.Text = "52") Then PictureBox52.Visible = True
            If PictureBox52.Visible = True Then BringToFront()
            If (Label1.Text = "53") Then PictureBox53.Visible = True
            If PictureBox53.Visible = True Then BringToFront()
            If (Label1.Text = "54") Then PictureBox54.Visible = True
            If PictureBox54.Visible = True Then BringToFront()
            If (Label1.Text = "55") Then PictureBox55.Visible = True
            If PictureBox55.Visible = True Then BringToFront()
            If (Label1.Text = "56") Then PictureBox56.Visible = True
            If PictureBox56.Visible = True Then BringToFront()
            If (Label1.Text = "57") Then PictureBox57.Visible = True
            If PictureBox57.Visible = True Then BringToFront()
            If (Label1.Text = "58") Then PictureBox58.Visible = True
            If PictureBox58.Visible = True Then BringToFront()
            If (Label1.Text = "59") Then PictureBox59.Visible = True
            If PictureBox59.Visible = True Then BringToFront()
            If (Label1.Text = "60") Then PictureBox60.Visible = True
            If PictureBox60.Visible = True Then BringToFront()
            If (Label1.Text = "61") Then PictureBox61.Visible = True
            If PictureBox61.Visible = True Then BringToFront()
            If (Label1.Text = "62") Then PictureBox62.Visible = True
            If PictureBox62.Visible = True Then BringToFront()
            If (Label1.Text = "63") Then PictureBox63.Visible = True
            If PictureBox63.Visible = True Then BringToFront()
            If (Label1.Text = "64") Then PictureBox64.Visible = True
            If PictureBox64.Visible = True Then BringToFront()
            If (Label1.Text = "65") Then PictureBox65.Visible = True
            If PictureBox65.Visible = True Then BringToFront()
            If (Label1.Text = "66") Then PictureBox66.Visible = True
            If PictureBox66.Visible = True Then BringToFront()
            If (Label1.Text = "67") Then PictureBox67.Visible = True
            If PictureBox67.Visible = True Then BringToFront()
            If (Label1.Text = "68") Then PictureBox68.Visible = True
            If PictureBox68.Visible = True Then BringToFront()
            If (Label1.Text = "69") Then PictureBox69.Visible = True
            If PictureBox69.Visible = True Then BringToFront()
            If (Label1.Text = "70") Then PictureBox70.Visible = True
            If PictureBox70.Visible = True Then BringToFront()
            If (Label1.Text = "71") Then PictureBox71.Visible = True
            If PictureBox71.Visible = True Then BringToFront()
            If (Label1.Text = "72") Then PictureBox72.Visible = True
            If PictureBox72.Visible = True Then BringToFront()
            If (Label1.Text = "73") Then PictureBox73.Visible = True
            If PictureBox73.Visible = True Then BringToFront()
            If (Label1.Text = "74") Then PictureBox74.Visible = True
            If PictureBox74.Visible = True Then BringToFront()
            If (Label1.Text = "75") Then PictureBox75.Visible = True
            If PictureBox75.Visible = True Then BringToFront()
            If (Label1.Text = "76") Then PictureBox76.Visible = True
            If PictureBox76.Visible = True Then BringToFront()
            If (Label1.Text = "77") Then PictureBox77.Visible = True
            If PictureBox77.Visible = True Then BringToFront()
            If (Label1.Text = "78") Then PictureBox78.Visible = True
            If PictureBox78.Visible = True Then BringToFront()
            If (Label1.Text = "79") Then PictureBox79.Visible = True
            If PictureBox79.Visible = True Then BringToFront()
            If (Label1.Text = "80") Then PictureBox80.Visible = True
            If PictureBox80.Visible = True Then BringToFront()
            If (Label1.Text = "81") Then PictureBox81.Visible = True
            If PictureBox81.Visible = True Then BringToFront()
            If (Label1.Text = "82") Then PictureBox82.Visible = True
            If PictureBox82.Visible = True Then BringToFront()
            If (Label1.Text = "83") Then PictureBox83.Visible = True
            If PictureBox83.Visible = True Then BringToFront()
            If (Label1.Text = "84") Then PictureBox84.Visible = True
            If PictureBox84.Visible = True Then BringToFront()
            If (Label1.Text = "85") Then PictureBox85.Visible = True
            If PictureBox85.Visible = True Then BringToFront()
            If (Label1.Text = "86") Then PictureBox86.Visible = True
            If PictureBox86.Visible = True Then BringToFront()
            If (Label1.Text = "87") Then PictureBox87.Visible = True
            If PictureBox87.Visible = True Then BringToFront()
            If (Label1.Text = "88") Then PictureBox88.Visible = True
            If PictureBox88.Visible = True Then BringToFront()
            If (Label1.Text = "89") Then PictureBox89.Visible = True
            If PictureBox89.Visible = True Then BringToFront()
            If (Label1.Text = "90") Then PictureBox90.Visible = True
            If PictureBox90.Visible = True Then BringToFront()
            If (Label1.Text = "91") Then PictureBox91.Visible = True
            If PictureBox91.Visible = True Then BringToFront()
            If (Label1.Text = "92") Then PictureBox92.Visible = True
            If PictureBox37.Visible = True Then BringToFront()
            If (Label1.Text = "93") Then PictureBox93.Visible = True
            If PictureBox93.Visible = True Then BringToFront()
            If (Label1.Text = "94") Then PictureBox94.Visible = True
            If PictureBox94.Visible = True Then BringToFront()
            If (Label1.Text = "95") Then PictureBox95.Visible = True
            If PictureBox95.Visible = True Then BringToFront()
            If (Label1.Text = "96") Then PictureBox96.Visible = True
            If PictureBox96.Visible = True Then BringToFront()
            If (Label1.Text = "97") Then PictureBox97.Visible = True
            If PictureBox97.Visible = True Then BringToFront()
            If (Label1.Text = "98") Then PictureBox98.Visible = True
            If PictureBox98.Visible = True Then BringToFront()
            If (Label1.Text = "99") Then PictureBox99.Visible = True
            If PictureBox99.Visible = True Then BringToFront()
            If (Label1.Text = "100") Then PictureBox100.Visible = True
            If PictureBox100.Visible = True Then BringToFront()


Admin Edit: Please use code tags when posting your code. Code tags are used like so => :code:

Thanks,
PsychoCoder :)

Is This A Good Question/Topic? 0
  • +

Replies To: Card game

#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1638
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Card game

Posted 05 May 2010 - 11:25 AM

Since this is VB.NET code and not VB6 code I'll move it to the VB.NET forum for ya :)
Was This Post Helpful? 0
  • +
  • -

#3 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1043
  • View blog
  • Posts: 4,054
  • Joined: 02-July 08

Re: Card game

Posted 05 May 2010 - 12:28 PM

Most of your text numbers match, so you could use this:
(If your PBs are on the form directly)
Me.Controls("PictureBox" & label1.Text).Visible = True

Was This Post Helpful? 0
  • +
  • -

#4 JonA40  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 04-May 10

Re: Card game

Posted 05 May 2010 - 01:46 PM

how does a ME statement work,
sorry im not familiar with a me.controls
would i not have to list each list and picturebox, ?
Was This Post Helpful? 0
  • +
  • -

#5 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1638
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Card game

Posted 05 May 2010 - 01:50 PM

Me is a VB.NET keyword that simply refers to the current object, in this case your form. Read this for more information
Was This Post Helpful? 0
  • +
  • -

#6 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1043
  • View blog
  • Posts: 4,054
  • Joined: 02-July 08

Re: Card game

Posted 05 May 2010 - 02:02 PM

I was using my code in place of your If/Else...Then. Your controls are indexed and in the container collect by name. Me.Controls is the control collection for the form. So if your looking for a control named PictureBox89 and label1.Text = "89" then Me.Controls("PictureBox" & label1.Text) is PictureBox89.

This post has been edited by hawkvalley1: 05 May 2010 - 02:03 PM

Was This Post Helpful? 0
  • +
  • -

#7 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1043
  • View blog
  • Posts: 4,054
  • Joined: 02-July 08

Re: Card game

Posted 05 May 2010 - 02:27 PM

While we are on the subject if you need a control-specific property for that control you will need to cast the type first. Here are the members that do not require casting i.e. Text, Name, Visible, etc... Control members!

If you need to set the ImageLocation then you would need to do this:

CType(Me.Controls("PictureBox" & label1.Text), PictureBox).ImageLocation = <something>


Also there are a lot a PBs why not just change the Image in a few PBs based on your needs.

This post has been edited by hawkvalley1: 05 May 2010 - 04:26 PM

Was This Post Helpful? 0
  • +
  • -

#8 lozthegreat1  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 17
  • Joined: 29-April 10

Re: Card game

Posted 05 May 2010 - 06:34 PM

Hey im not sure if this will be any help to you but if you go to microsoft.msdn
and look theres a card game that you can download you could use it for some inspiration

appart from that i cant help any more than that

oh one more thing instead of using picbox.visible

you could use like 5 picboxes and import all your images into my resourses and when you want it to change just uses like me.resourses/images and so on so forth

i dont know if this help hope it does and good luck on your project :dontgetit:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1