Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[C#] Buttons

Elite Diviner
Joined
Jan 26, 2006
Messages
483
Reaction score
5
Heya,

So im working currently on a blackjack application.
My application have 5 buttons:

Start
Hit me (Give new card to player)
Stand (Stop giving new cards and let computer play)
Reset
Exit

Now the I have a problem with the first 2 buttons:

I want the start button to be clicked only once (otherwise you can click as many times as you want to get good cards) how do you set a click limit on the button.

The next problem with the HitMe button:

Im using pictureboxes for the cards which got different names of course.
So the first time you click the picturebox name must be Player_Card3 second time Player_Card4 and so on...

Here a little part of my code you might need to help me :rolleyes:

Code:
Random start = new Random(); //RANDOM NUMBER
Bitmap myStartCard;

 private void Hit_btn_Click(object sender, EventArgs e)
{//START HITMEBUTTON
            
int x = start.Next(0, 13);
if (x == 0)
{
myStartCard = new Bitmap(ace);
}

[U][B]Player_Card1.Image = myStartCard;[/B][/U]
           
}//END HITMEBUTTON

So as you can see the bold underlined line needs to change its digit every time you click the hitme button
 
Elite Diviner
Joined
Jan 26, 2006
Messages
483
Reaction score
5
Yup that will not enable the button at all.
So I came up with this little code:
Code:
{ // BUTTON START

{
My code
}
start.btn.Enabled = false;
} // BUTTON END

Which worked like a charm so thanks for ur help ^^
 
Last edited:
Elite Diviner
Joined
Jan 26, 2006
Messages
483
Reaction score
5
haha yup true well anyway I fixed the HitMe button problem aswell.
Just made a int variable and in the click block it counts every time +1.
And then a simple if statement which looks to what image box it need to be sended. Im sure there is a better way and im always intressed learning it so if you got a idea how to do it better just write a reply ^^
 
Back
Top