さて、私はプログラムを書いていますが、ユーザーがプログラムを起動するたびに生成される特定のボタンをランダムな回数 (1 ~ 25 回) だけクリックできるようにする必要があります。私のコードはこれに対して機能していません。プログラムは現在、リストボックスに合計値を保持しており、ユーザーがボタンを押すことができる「制限」量に達すると、その合計値を既に保存したファイルに書き込むと想定しています. また、この「ランダムな回数」がアクティブになったときのメッセージ ショーをどのように組み込みますか? これが私のコードです、ありがとう:
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");
}