473,327 Members | 2,025 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,327 software developers and data experts.

Timed Random number in 2005 Express

i have been trying to set a amount of time a random number has

like

Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3.       TextBox6.Text = CStr(Int(Rnd() * 10))
  4.  
  5. ' This variable will be the loop counter.
  6. Private counter As Integer
  7.  
  8. Private Sub InitializeTimer()
  9.    ' Run this procedure in an appropriate event.
  10.    counter = 0
  11.    Timer1.Interval = 600
  12.    Timer1.Enabled = True
  13. End Sub
  14.  
  15. Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
  16.    If counter => 10 Then
  17.       ' Exit loop code.
  18.       Timer1.Enabled = False
  19.       counter = 0
  20.    Else
  21.       ' Run your procedure here.
  22.       ' Increment counter.
  23.       counter = counter + 1
  24.       TextBox6.Text = counter.ToString
  25.    End If
  26. End Sub
  27.  


I can get the timer to run and the radom number to run but i cant seem to do both at the same time

I would like a timed random number generatered at a set amount of time
Thanks
Feb 9 '08 #1
1 1052
Bum
19
why don't you

Code: ( text )

' This variable will be the loop counter.
Private counter As Integer

Private Sub InitializeTimer()
' Run this procedure in an appropriate event.
counter = 0
Timer1.Interval = 600
Timer1.Enabled = True
End Sub

Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If counter => 10 Then
' Exit loop code.
Timer1.Enabled = False
counter = 0
Else
' Run your procedure here.
' Increment counter.
counter = counter + 1
TextBox5.Text = CStr(Int(Rnd() * 10))
TextBox6.Text = counter.ToString
End If
End Sub

you might want to use doevents, too
Feb 14 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Joe | last post by:
I'm hosting my web service on a Windows 2003 box which is remotely located. When trying to add a web reference to a C# project I get an error message 'There was an error downloading...
38
by: One Handed Man \( OHM - Terry Burns \) | last post by:
I have a basic question thats been niggling me, but I never found time to look at it before. If I have an enumeration such as this Fiend Enum TravelDirection North South East
3
by: sebnunes | last post by:
Hi all, I have a strange behavior with the ASP .NET 2.0 Admin tool. When I click on ASP.NET Configuration in VS 2005 the Administration intro page displays correctly but when I click on any...
26
by: Jimmy | last post by:
ill have a database with 1 table and 3 fields: ID FIRSTNAME LASTNAME (the ID field will be the auto incrementing index) there might be 10 records in the DB, there might be 10,000. i...
12
by: Pascal | last post by:
hello and soory for my english here is the query :"how to split a string in a random way" I try my first shot in vb 2005 express and would like to split a number in several pieces in a random way...
12
by: Juha Nieminen | last post by:
I'm trying to use a random number generator and rand() is just not up to the task (RAND_MAX is way too small). I searched in the help system and found the System::Random class which seems to be...
0
SammyB
by: SammyB | last post by:
These are some "random" thoughts about generating random numbers in Visual Basic. Wikipedia will give a better introduction than I, see http://en.wikipedia.org/wiki/Random_number_generator. ...
13
by: Peter Oliphant | last post by:
I would like to be able to create a random number generator that produces evenly distributed random numbers up to given number. For example, I would like to pick a random number less than 100000,...
11
by: Masud | last post by:
hi, for a test i want to generate different random numbers between different ranges in a single loop. I tried to solve in the following way but it always profile same value. I am looking for...
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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.