Exe file wont open!

Pages: 12
According to:
http://msdn.microsoft.com/en-us/library/system.windows.forms.form.load(v=vs.110).aspx
Form::Load occurs only once.

If you want it to run on Form::Load use something relating to the time. Like:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <time.h>
#include <iostream>

int main()
{
  long int CurrentTime=static_cast<long int>(time(NULL));
  if(((CurrentTime*10000)%5)==0)
  {
    std::cout << "Red" << std::endl;
  }
  else if(((CurrentTime*10000)%5)==1)
  {
    std::cout << "Blue" << std::endl;
  }
  //2 and 3 (yellow and green) [too lazy to type them out, but you get the point]
  else if(((CurrentTime*10000)%5)==4)
  {
    std::cout << "Purple" << std::endl;
  }
  return 0;
}
Thanks again,

But this doesn't explain why it always loads on the colour blue when the program is first loaded. I would have thought that the randomisation would generate any of colours when first loaded. As I said before it does change colour scrolling through the forms of my actual program. Ill give your code a go a little later today and let you know how it goes. Thanks for you help and advice.
Strange.

-EDIT-

Maybe take a look at this:
http://www.cplusplus.com/reference/random/?kw=random
Last edited on
Topic archived. No new replies allowed.
Pages: 12