473,322 Members | 1,287 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Problem with Random()

If I use it in my page it's fine but when I put it in a Class file for
calling it returns the same # for each call.
Any ideas why? I'm sure it's something I'll slap myself for but the only
samples I can find are for calling the Random() within the page, not a
seperate class.

--Page--
myClass myclass = new myClass();
for(int i = 1;i <= 100; i++)
{
this.myLabel.Text += i + " - " + myClass.GetRandom() + "<br>";
}

---- class file
public string GetRandom()
{
Random rnd = new Random();
return rnd.Next(1,100));
}

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com

Nov 18 '05 #1
10 1620
The random number generation starts from a seed value. If the same seed is
used repeatedly, the same series of numbers is generated. One way to produce
different sequences is to make the seed value time-dependent, thereby
producing a different series with each new instance of Random.

To improve performance, create one Random to generate many random numbers
over time, instead of repeatedly creating a new Random to generate one
random number.

extract from msdn. Time Dependant seed.
--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:e0**************@TK2MSFTNGP11.phx.gbl...
If I use it in my page it's fine but when I put it in a Class file for
calling it returns the same # for each call.
Any ideas why? I'm sure it's something I'll slap myself for but the only
samples I can find are for calling the Random() within the page, not a
seperate class.

--Page--
myClass myclass = new myClass();
for(int i = 1;i <= 100; i++)
{
this.myLabel.Text += i + " - " + myClass.GetRandom() + "<br>";
}

---- class file
public string GetRandom()
{
Random rnd = new Random();
return rnd.Next(1,100));
}

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com

Nov 18 '05 #2
I had tried with the seed being System.DateTime.Now.Millisecond but my
numbers must generate too fast for that to work. Must need nanosecond I
guess........

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> wrote in message
news:uv**************@TK2MSFTNGP15.phx.gbl...
The random number generation starts from a seed value. If the same seed is
used repeatedly, the same series of numbers is generated. One way to
produce
different sequences is to make the seed value time-dependent, thereby
producing a different series with each new instance of Random.

To improve performance, create one Random to generate many random numbers
over time, instead of repeatedly creating a new Random to generate one
random number.

extract from msdn. Time Dependant seed.
--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:e0**************@TK2MSFTNGP11.phx.gbl...
If I use it in my page it's fine but when I put it in a Class file for
calling it returns the same # for each call.
Any ideas why? I'm sure it's something I'll slap myself for but the only
samples I can find are for calling the Random() within the page, not a
seperate class.

--Page--
myClass myclass = new myClass();
for(int i = 1;i <= 100; i++)
{
this.myLabel.Text += i + " - " + myClass.GetRandom() + "<br>";
}

---- class file
public string GetRandom()
{
Random rnd = new Random();
return rnd.Next(1,100));
}

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com


Nov 18 '05 #3
i know it still doesnt explain
If I use it in my page it's fine but when I put it in a Class >file for calling it returns the same # for each call.

I did look around if i find anything i will drop in a message

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> wrote in message
news:uv**************@TK2MSFTNGP15.phx.gbl... The random number generation starts from a seed value. If the same seed is
used repeatedly, the same series of numbers is generated. One way to produce different sequences is to make the seed value time-dependent, thereby
producing a different series with each new instance of Random.

To improve performance, create one Random to generate many random numbers
over time, instead of repeatedly creating a new Random to generate one
random number.

extract from msdn. Time Dependant seed.
--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:e0**************@TK2MSFTNGP11.phx.gbl...
If I use it in my page it's fine but when I put it in a Class file for
calling it returns the same # for each call.
Any ideas why? I'm sure it's something I'll slap myself for but the only
samples I can find are for calling the Random() within the page, not a
seperate class.

--Page--
myClass myclass = new myClass();
for(int i = 1;i <= 100; i++)
{
this.myLabel.Text += i + " - " + myClass.GetRandom() + "<br>";
}

---- class file
public string GetRandom()
{
Random rnd = new Random();
return rnd.Next(1,100));
}

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com


Nov 18 '05 #4
another lame attempt at trying to read between lines

Represents a pseudo-random number generator, a device that produces a
sequence of numbers that meet certain statistical requirements for
randomness.

this is more of a 'Can you do it this way'

how about making your Random class wrapper as Static
and making the last ramdom as static variable which is used as a seed for
the next() method !!

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:eC**************@TK2MSFTNGP15.phx.gbl...
I had tried with the seed being System.DateTime.Now.Millisecond but my
numbers must generate too fast for that to work. Must need nanosecond I
guess........

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> wrote in message
news:uv**************@TK2MSFTNGP15.phx.gbl...
The random number generation starts from a seed value. If the same seed is used repeatedly, the same series of numbers is generated. One way to
produce
different sequences is to make the seed value time-dependent, thereby
producing a different series with each new instance of Random.

To improve performance, create one Random to generate many random numbers over time, instead of repeatedly creating a new Random to generate one
random number.

extract from msdn. Time Dependant seed.
--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:e0**************@TK2MSFTNGP11.phx.gbl...
If I use it in my page it's fine but when I put it in a Class file for
calling it returns the same # for each call.
Any ideas why? I'm sure it's something I'll slap myself for but the only samples I can find are for calling the Random() within the page, not a
seperate class.

--Page--
myClass myclass = new myClass();
for(int i = 1;i <= 100; i++)
{
this.myLabel.Text += i + " - " + myClass.GetRandom() + "<br>";
}

---- class file
public string GetRandom()
{
Random rnd = new Random();
return rnd.Next(1,100));
}

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com



Nov 18 '05 #5
have a look at http://hdave.myvnc.com/WebApplication1/WebForm1.aspx

public class MyClass
{
Random rdm1;
Random rdm2;
int seed = 1;
int Max = 100;
public MyClass()
{
//
// TODO: Add constructor logic here
//
rdm1 = new Random();
rdm2 = new Random(seed);
}
public int GetRandon11()
{
return rdm1.Next(seed, Max);
}
public int GetRandom21()
{
return rdm1.Next(seed, Max);
}
}

it's sort of working fine. need some dinner now.. brb

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:e0**************@TK2MSFTNGP11.phx.gbl...
If I use it in my page it's fine but when I put it in a Class file for
calling it returns the same # for each call.
Any ideas why? I'm sure it's something I'll slap myself for but the only
samples I can find are for calling the Random() within the page, not a
seperate class.

--Page--
myClass myclass = new myClass();
for(int i = 1;i <= 100; i++)
{
this.myLabel.Text += i + " - " + myClass.GetRandom() + "<br>";
}

---- class file
public string GetRandom()
{
Random rnd = new Random();
return rnd.Next(1,100));
}

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com

Nov 18 '05 #6
Curt,

Out of interest, try using the tickcount as the seed

--
Regards

John Timney
Microsoft Regional Director
Microsoft MVP
"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:eC**************@TK2MSFTNGP15.phx.gbl...
I had tried with the seed being System.DateTime.Now.Millisecond but my
numbers must generate too fast for that to work. Must need nanosecond I
guess........

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> wrote in message
news:uv**************@TK2MSFTNGP15.phx.gbl...
The random number generation starts from a seed value. If the same seed is used repeatedly, the same series of numbers is generated. One way to
produce
different sequences is to make the seed value time-dependent, thereby
producing a different series with each new instance of Random.

To improve performance, create one Random to generate many random numbers over time, instead of repeatedly creating a new Random to generate one
random number.

extract from msdn. Time Dependant seed.
--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:e0**************@TK2MSFTNGP11.phx.gbl...
If I use it in my page it's fine but when I put it in a Class file for
calling it returns the same # for each call.
Any ideas why? I'm sure it's something I'll slap myself for but the only samples I can find are for calling the Random() within the page, not a
seperate class.

--Page--
myClass myclass = new myClass();
for(int i = 1;i <= 100; i++)
{
this.myLabel.Text += i + " - " + myClass.GetRandom() + "<br>";
}

---- class file
public string GetRandom()
{
Random rnd = new Random();
return rnd.Next(1,100));
}

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com



Nov 18 '05 #7
i think the sole reason it think he had the problem was that he was creating
an instance with every call and i think as msdn states it products pseudo
randomness as long as you use the same object.

i have tried it with using the same object rather than creating and
disposing instance per call and it works just fine

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"John Timney (Microsoft MVP)" <ti*****@despammed.com> wrote in message
news:e5**************@TK2MSFTNGP09.phx.gbl...
Curt,

Out of interest, try using the tickcount as the seed

--
Regards

John Timney
Microsoft Regional Director
Microsoft MVP
"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:eC**************@TK2MSFTNGP15.phx.gbl...
I had tried with the seed being System.DateTime.Now.Millisecond but my
numbers must generate too fast for that to work. Must need nanosecond I
guess........

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> wrote in message
news:uv**************@TK2MSFTNGP15.phx.gbl...
The random number generation starts from a seed value. If the same seed
is used repeatedly, the same series of numbers is generated. One way to
produce
different sequences is to make the seed value time-dependent, thereby
producing a different series with each new instance of Random.

To improve performance, create one Random to generate many random numbers over time, instead of repeatedly creating a new Random to generate one
random number.

extract from msdn. Time Dependant seed.
--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:e0**************@TK2MSFTNGP11.phx.gbl...
> If I use it in my page it's fine but when I put it in a Class file
for> calling it returns the same # for each call.
> Any ideas why? I'm sure it's something I'll slap myself for but the

only> samples I can find are for calling the Random() within the page, not a> seperate class.
>
> --Page--
> myClass myclass = new myClass();
> for(int i = 1;i <= 100; i++)
> {
> this.myLabel.Text += i + " - " + myClass.GetRandom() + "<br>";
> }
>
> ---- class file
> public string GetRandom()
> {
> Random rnd = new Random();
> return rnd.Next(1,100));
> }
>
> --
> Curt Christianson
> Owner/Lead Developer, DF-Software
> Site: http://www.Darkfalz.com
> Blog: http://blog.Darkfalz.com
>
>
>



Nov 18 '05 #8
Actually I had tried it both ways. The execution was to fast for the seed to
the the tickcount or now.millisecond so what I did was in each iteration I
increased the ((seed + 1) * pi) to get a new number. Using seed++ ended up
giving me an easily distinguishable pattern.

Thanks for the help all. That darn seed thing is just goofy, and not
documented well.
I read it and thought it was the time/duration that the current iteration
would maintian uniqueness, guess you learn.

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> wrote in message
news:O5****************@TK2MSFTNGP09.phx.gbl...
i think the sole reason it think he had the problem was that he was
creating
an instance with every call and i think as msdn states it products pseudo
randomness as long as you use the same object.

i have tried it with using the same object rather than creating and
disposing instance per call and it works just fine

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"John Timney (Microsoft MVP)" <ti*****@despammed.com> wrote in message
news:e5**************@TK2MSFTNGP09.phx.gbl...
Curt,

Out of interest, try using the tickcount as the seed

--
Regards

John Timney
Microsoft Regional Director
Microsoft MVP
"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:eC**************@TK2MSFTNGP15.phx.gbl...
> I had tried with the seed being System.DateTime.Now.Millisecond but my
> numbers must generate too fast for that to work. Must need nanosecond I
> guess........
>
> --
> Curt Christianson
> Owner/Lead Developer, DF-Software
> Site: http://www.Darkfalz.com
> Blog: http://blog.Darkfalz.com
>
>
> "Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> wrote in message > news:uv**************@TK2MSFTNGP15.phx.gbl...
> > The random number generation starts from a seed value. If the same seed
is
> > used repeatedly, the same series of numbers is generated. One way to
> > produce
> > different sequences is to make the seed value time-dependent, thereby
> > producing a different series with each new instance of Random.
> >
> > To improve performance, create one Random to generate many random

numbers
> > over time, instead of repeatedly creating a new Random to generate
> > one
> > random number.
> >
> > extract from msdn. Time Dependant seed.
> >
> >
> > --
> >
> > Regards,
> >
> > Hermit Dave
> > (http://hdave.blogspot.com)
> > "Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
> > news:e0**************@TK2MSFTNGP11.phx.gbl...
> >> If I use it in my page it's fine but when I put it in a Class file

for > >> calling it returns the same # for each call.
> >> Any ideas why? I'm sure it's something I'll slap myself for but the

only
> >> samples I can find are for calling the Random() within the page, not a > >> seperate class.
> >>
> >> --Page--
> >> myClass myclass = new myClass();
> >> for(int i = 1;i <= 100; i++)
> >> {
> >> this.myLabel.Text += i + " - " + myClass.GetRandom() + "<br>";
> >> }
> >>
> >> ---- class file
> >> public string GetRandom()
> >> {
> >> Random rnd = new Random();
> >> return rnd.Next(1,100));
> >> }
> >>
> >> --
> >> Curt Christianson
> >> Owner/Lead Developer, DF-Software
> >> Site: http://www.Darkfalz.com
> >> Blog: http://blog.Darkfalz.com
> >>
> >>
> >>
> >
> >
>
>



Nov 18 '05 #9
I'm suprised that the execution was too fast for tickcount, I thought that
was impossible. Glad you have a solution anyway and I agree that seeding is
darn goofy.

--
Regards

John Timney
Microsoft Regional Director
Microsoft MVP
"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:Ob**************@TK2MSFTNGP11.phx.gbl...
Actually I had tried it both ways. The execution was to fast for the seed to the the tickcount or now.millisecond so what I did was in each iteration I
increased the ((seed + 1) * pi) to get a new number. Using seed++ ended up
giving me an easily distinguishable pattern.

Thanks for the help all. That darn seed thing is just goofy, and not
documented well.
I read it and thought it was the time/duration that the current iteration
would maintian uniqueness, guess you learn.

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> wrote in message
news:O5****************@TK2MSFTNGP09.phx.gbl...
i think the sole reason it think he had the problem was that he was
creating
an instance with every call and i think as msdn states it products pseudo randomness as long as you use the same object.

i have tried it with using the same object rather than creating and
disposing instance per call and it works just fine

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"John Timney (Microsoft MVP)" <ti*****@despammed.com> wrote in message
news:e5**************@TK2MSFTNGP09.phx.gbl...
Curt,

Out of interest, try using the tickcount as the seed

--
Regards

John Timney
Microsoft Regional Director
Microsoft MVP
"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:eC**************@TK2MSFTNGP15.phx.gbl...
> I had tried with the seed being System.DateTime.Now.Millisecond but my > numbers must generate too fast for that to work. Must need nanosecond I > guess........
>
> --
> Curt Christianson
> Owner/Lead Developer, DF-Software
> Site: http://www.Darkfalz.com
> Blog: http://blog.Darkfalz.com
>
>
> "Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> wrote in

message
> news:uv**************@TK2MSFTNGP15.phx.gbl...
> > The random number generation starts from a seed value. If the same

seed
is
> > used repeatedly, the same series of numbers is generated. One way to > > produce
> > different sequences is to make the seed value time-dependent, thereby > > producing a different series with each new instance of Random.
> >
> > To improve performance, create one Random to generate many random
numbers
> > over time, instead of repeatedly creating a new Random to generate
> > one
> > random number.
> >
> > extract from msdn. Time Dependant seed.
> >
> >
> > --
> >
> > Regards,
> >
> > Hermit Dave
> > (http://hdave.blogspot.com)
> > "Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
> > news:e0**************@TK2MSFTNGP11.phx.gbl...
> >> If I use it in my page it's fine but when I put it in a Class file

for
> >> calling it returns the same # for each call.
> >> Any ideas why? I'm sure it's something I'll slap myself for but the only
> >> samples I can find are for calling the Random() within the page,
not a
> >> seperate class.
> >>
> >> --Page--
> >> myClass myclass = new myClass();
> >> for(int i = 1;i <= 100; i++)
> >> {
> >> this.myLabel.Text += i + " - " + myClass.GetRandom() + "<br>";
> >> }
> >>
> >> ---- class file
> >> public string GetRandom()
> >> {
> >> Random rnd = new Random();
> >> return rnd.Next(1,100));
> >> }
> >>
> >> --
> >> Curt Christianson
> >> Owner/Lead Developer, DF-Software
> >> Site: http://www.Darkfalz.com
> >> Blog: http://blog.Darkfalz.com
> >>
> >>
> >>
> >
> >
>
>



Nov 18 '05 #10
yeah, somehow it was.
I was runing it 10 times and would get 6,8, sometimes 10 of them the same.
Guess the machines have taken over.

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"John Timney (Microsoft MVP)" <ti*****@despammed.com> wrote in message
news:eS****************@tk2msftngp13.phx.gbl...
I'm suprised that the execution was too fast for tickcount, I thought that
was impossible. Glad you have a solution anyway and I agree that seeding
is
darn goofy.

--
Regards

John Timney
Microsoft Regional Director
Microsoft MVP
"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:Ob**************@TK2MSFTNGP11.phx.gbl...
Actually I had tried it both ways. The execution was to fast for the seed

to
the the tickcount or now.millisecond so what I did was in each iteration
I
increased the ((seed + 1) * pi) to get a new number. Using seed++ ended
up
giving me an easily distinguishable pattern.

Thanks for the help all. That darn seed thing is just goofy, and not
documented well.
I read it and thought it was the time/duration that the current iteration
would maintian uniqueness, guess you learn.

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> wrote in message
news:O5****************@TK2MSFTNGP09.phx.gbl...
>i think the sole reason it think he had the problem was that he was
>creating
> an instance with every call and i think as msdn states it products pseudo > randomness as long as you use the same object.
>
> i have tried it with using the same object rather than creating and
> disposing instance per call and it works just fine
>
> --
>
> Regards,
>
> Hermit Dave
> (http://hdave.blogspot.com)
> "John Timney (Microsoft MVP)" <ti*****@despammed.com> wrote in message
> news:e5**************@TK2MSFTNGP09.phx.gbl...
>> Curt,
>>
>> Out of interest, try using the tickcount as the seed
>>
>> --
>> Regards
>>
>> John Timney
>> Microsoft Regional Director
>> Microsoft MVP
>>
>>
>> "Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
>> news:eC**************@TK2MSFTNGP15.phx.gbl...
>> > I had tried with the seed being System.DateTime.Now.Millisecond but my >> > numbers must generate too fast for that to work. Must need
>> > nanosecond I >> > guess........
>> >
>> > --
>> > Curt Christianson
>> > Owner/Lead Developer, DF-Software
>> > Site: http://www.Darkfalz.com
>> > Blog: http://blog.Darkfalz.com
>> >
>> >
>> > "Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> wrote in
> message
>> > news:uv**************@TK2MSFTNGP15.phx.gbl...
>> > > The random number generation starts from a seed value. If the same
> seed
>> is
>> > > used repeatedly, the same series of numbers is generated. One way to >> > > produce
>> > > different sequences is to make the seed value time-dependent, thereby >> > > producing a different series with each new instance of Random.
>> > >
>> > > To improve performance, create one Random to generate many random
>> numbers
>> > > over time, instead of repeatedly creating a new Random to generate
>> > > one
>> > > random number.
>> > >
>> > > extract from msdn. Time Dependant seed.
>> > >
>> > >
>> > > --
>> > >
>> > > Regards,
>> > >
>> > > Hermit Dave
>> > > (http://hdave.blogspot.com)
>> > > "Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
>> > > news:e0**************@TK2MSFTNGP11.phx.gbl...
>> > >> If I use it in my page it's fine but when I put it in a Class
>> > >> file
> for
>> > >> calling it returns the same # for each call.
>> > >> Any ideas why? I'm sure it's something I'll slap myself for but the >> only
>> > >> samples I can find are for calling the Random() within the page, not > a
>> > >> seperate class.
>> > >>
>> > >> --Page--
>> > >> myClass myclass = new myClass();
>> > >> for(int i = 1;i <= 100; i++)
>> > >> {
>> > >> this.myLabel.Text += i + " - " + myClass.GetRandom() + "<br>";
>> > >> }
>> > >>
>> > >> ---- class file
>> > >> public string GetRandom()
>> > >> {
>> > >> Random rnd = new Random();
>> > >> return rnd.Next(1,100));
>> > >> }
>> > >>
>> > >> --
>> > >> Curt Christianson
>> > >> Owner/Lead Developer, DF-Software
>> > >> Site: http://www.Darkfalz.com
>> > >> Blog: http://blog.Darkfalz.com
>> > >>
>> > >>
>> > >>
>> > >
>> > >
>> >
>> >
>>
>>
>
>



Nov 18 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Andrew Bonello | last post by:
Hi I have written a C++ program (Redhat Linux 7.2, gcc v2.96). The program makes a sequence of calls to rand() after having seeded the random number generator using srand( 0 ). Under normal...
7
by: Chris Gordon-Smith | last post by:
I have a simulation program that calls the rand() function at various points while it executes. For the user interface that displays statistics etc. while the program runs, I use the Lazarus GUI...
11
by: sudhaoncyberworld | last post by:
Hi all i am using asp.net v2.0 In one of my page i am calling another page using xml http , this is working fine but first time only , I am sending the request on click of button , when i...
7
by: Jean-Francois.Doyon | last post by:
Hello, I'm trying to retrieve a limited number of random rows, and order them by a column, and am not having any luck with that last part: SELECT * FROM tablename ORDER BY random(), id LIMIT...
5
by: Leonardo Hyppolito | last post by:
Hello! I am trying to implement a program that uses Threads. I chose the producers and consumers scenario. The producers put a "product" (which is an int number) in a shared storage place of one...
4
by: Leonardo Hyppolito | last post by:
Hello, I am trying to write a multithread program that simulates producers and consumers. My program can have many producers and many consumers (each in a separate thread). It has a storage...
7
by: Fernando Barsoba | last post by:
Hi, After following the advice received in this list, I have isolated the memory leak problem I am having. I am also using MEMWATCH and I think it is working properly. The program does some...
0
by: want2learn | last post by:
Hi. I have this CAPTCHA image for .Net in C-Sharp and translate it into VB and as Code_Behind. http://www.mbarrick.com/blog/d6plinks/20061221-01 If i run the site/script i get the site but...
5
by: Ray D. | last post by:
Okay, so I'm trying to typecast a random integer into a double, and store that in an array of doubles. Here is my code: void randomMatrix(double *x) { int i, random; // Generate...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.