Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7938199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:44:14+00:00 2026-06-03T22:44:14+00:00

So here is the basic code: namespace WindowsFormsApplication1 { public partial class Form1 :

  • 0

So here is the basic code:

    namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        protected Random random;

        public Form1()
        {
            InitializeComponent();
            random = new Random();
        }

        private void Form1_Load(object sender, EventArgs e)
        { }

        private void button1_Click(object sender, EventArgs e)
        {
            bool button1Clicked = true;
            if (button1Clicked == true) { ITIpanel.Visible = true; }
        }

        private void ITIpanel_Paint(object sender, PaintEventArgs e)
        {
            ITItimer.Enabled = true;
        }

        private void ITItimer_Tick(object sender, EventArgs e)
        {
            double rand = random.NextDouble();
            if (rand < .50d) { bluestimPanel.Visible = true; }
            else if (rand > .5d) { redstimPanel.Visible = true; }

            ITItimer.Enabled = false;
        }

        private void bluestimPanel_Paint(object sender, PaintEventArgs e)
        {
            Trialtimer.Enabled = true;
        }

        private void redstimPanel_Paint(object sender, PaintEventArgs e)
        {
            Trialtimer.Enabled = true;
        }

        private void Trialtimer_Tick(object sender, EventArgs e)
        {
            bluestimPanel.Visible = false;
            redstimPanel.Visible = false;
            Trialtimer.Enabled = false;
            ITIpanel.Visible = true;
        }
    }
}

As you can see, the program itself is fairly straight forward. At the tick of the ITItimer the red or blue panels occurs at random. I want to modify this such that if the ITItimer ticks a total of 10 times, the red and blue panels will both have occurred 5 times each.

I have been researching this for a week or so and have yet to find a solution. Any ideas on how I could best accomplish this?

I actually got the following to work:

double rand = random.NextDouble();
if (rand < .50d && blue < 5) { bluestimPanel.Visible = true; }
else if (blue == 5) { redstimPanel.Visible = true; }
if (rand > .5d && red < 5) { redstimPanel.Visible = true; }
else if (red == 5) { bluestimPanel.Visible = true; }
if (red >= 5 && blue >= 5) { panel1.Visible = true; } 

It isn’t exactly the prettiest thing in the world. But it gets the job done.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T22:44:15+00:00Added an answer on June 3, 2026 at 10:44 pm

    Random numbers using most normal library routines are a low-quality source of pseudorandomness. If this is for a randomized scientific study, this will be a flaw in your protocol design.

    The approach that I would recommend would be to consider this a method of randomly arranging a session of at least N trials, where there are X trial types.

    The below is pseudocode for illustration of the concept.

    Let MinimumTrials be N MOD X + X
    Let SessionList be a List<Trial>
    For Each TrialType 
        add X instances of that trial type to SessionList
    Shuffle(SessionList)
    

    Then your session engine can call the individual Trials as it walks through the SessionList to have an even distribution of possible trial orders. Note that Shuffle is an operation which requires a certain degree of finesse to get right, searching on SO is a good starting point for that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here one more basic question asked in MS interview recently class A { public
Here's some basic code to create a ListViewGroup, add it to the Groups collection
Really basic question here: I've seen a bunch of CoreAudio code that uses memset
I have the basic jQueryUI progress bar code here; <script> $(function() { $(#progressbar).progressbar({ value:
here is code which print c++ in binary form and at the same time
I have a totally basic C++ question here. #include <iostream> using namespace std; int
I'm trying a basic input,output(and append) in C++ here is my code #include <iostream>
Here's the code: #include <iostream> #include <string> #include <algorithm> using namespace std; int main()
I am missing something embarrassingly basic here in my Merge Sort implementation: # include
I'm sure I'm doing something really dumb and basic here but I can't seem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.