好的,所以我正在编写一个程序,它应该只允许用户单击某个按钮随机次数(1-25 次),这是每次用户启动程序时生成的。我的代码对此不起作用,该程序当前在 ListBox 中保留一个总计值,当用户点击他们可以点击按钮的“限制”数量时,它假设将该总计值写入我已经保存的文件. 另外,当激活此“随机次数”时,您将如何合并消息显示?这是我的代码,谢谢:
public Form1()
{
InitializeComponent();
}
private int lose()
{
// int High_Score;
Random rand = new Random();
lost = rand.Next(23) + 2;
return lost;
MessageBox.Show(" you lose");
}
private void begingameButton_Click(object sender, EventArgs e)
{
lose();
//Begin game button disable
begingameButton.Enabled = false;
//The roll button is enabled
rolldieButton.Enabled = true;
//Makes the beginning instructions visible
beginLabel.Visible = false;
//Makes the other instructions visible
diceBox1.Visible = true;
//Enables the start over button
startoverButton.Enabled = true;
//Displays a total of 0 dollars at the beginning of game
int beginTotal = 0;
totalmoneyLabel.Text = beginTotal.ToString("c");
}