Hi @Anonymous ,
The following code can generate random numbers in C++ Winform, you could refer to it.
private:
System::Void button1_Click(System::Object ^ sender,
System::EventArgs ^ e) {
Random ^ran = gcnew Random();
int RandKey = ran->Next(0, 15); //Generate random number
textBox1->Text = RandKey.ToString(); //Display random number
}
PS: This code is just for demonstration, you don't necessarily need textbox or button to trigger the event.
Best regards,
Elya
If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.