Hi all,
Sorry im beginer in vb.
I want making programm looping character or number.
Just say i have numbers from 100 to 10000.
just sample:
Private Sub Timer1_Timer()
if check1.value= 1 then
for i = 100 to 10000
text1.text= i
next i
end if
end sub
but this looping not like i wanted,
I want all number until the end will be display on text1.text, not just the last number 10000. We can see what the value on text1.text when looping running.
If value of i = 10000 then repeat again from the begining until check box value=0,
when click check box the looping stop, the result text1 can be = 100 or 500 or 300 or 9000 or etc..
any suggestion or code script else?...
please help..
thanks in advance
20 2791
Hi all,
Sorry im beginer in vb.
I want making programm looping character or number.
Just say i have numbers from 100 to 10000.
just sample:
Private Sub Timer1_Timer()
if check1.value= 1 then
for i = 100 to 10000
text1.text= i
next i
end if
end sub
but this looping not like i wanted,
I want all number until the end will be display on text1.text, not just the last number 10000. We can see what the value on text1.text when looping running.
If value of i = 10000 then repeat again from the begining until check box value=0,
when click check box the looping stop, the result text1 can be = 100 or 500 or 300 or 9000 or etc..
any suggestion or code script else?...
please help..
thanks in advance
So u can use - Private Sub Timer1_Timer()
-
text1.text = ""
-
if check1.value= 1 then
-
for i = 100 to 10000
-
text1.text = text1.text & " " & i
-
next i
-
end if
-
-
end sub
this will help u
Actually Ifoel, I think your original code will work, if you put a DoEvents statement inside the loop. This allows Windows to take time out to do other things, like updating the display.
(You might also need to Refresh the form, but I don't think so.)
Thanks alot Killer42 and Hariharanmca...........
this very help full
.....
So u can use - Private Sub Timer1_Timer()
-
text1.text = ""
-
if check1.value= 1 then
-
for i = 100 to 10000
-
text1.text = text1.text & " " & i
-
next i
-
end if
-
-
end sub
this will help u
I don't have VB in my system so i cannot test tat so i'm giving hint tatsall....
Hi Hariharanmca
thanks for u reply...
My original code has corect, like Killer42 said. I just add DoEvents in loop.
now i get trouble, when i click check box for stop looping, why looping still running. and value of Text1.text always 10000.
i have put code when value check1 box = 0, timer1.enable=false.
why this haven?. how to directly stop looping when timer1 false?
so i can get value on text1.text like i wish..
i mean when looping running and on value text1.text box=500 when i press check1 box to stop looping should be value text1.text=500 not 10000.
any idea or script else?
thanks in advance
Hi Hariharanmca
thanks for u reply...
My original code has corect, like Killer42 said. I just add DoEvents in loop.
now i get trouble, when i click check box for stop looping, why looping still running. and value of Text1.text always 10000.
i have put code when value check1 box = 0, timer1.enable=false.
why this haven?. how to directly stop looping when timer1 false?
so i can get value on text1.text like i wish..
i mean when looping running and on value text1.text box=500 when i press check1 box to stop looping should be value text1.text=500 not 10000.
any idea or script else?
thanks in advance
Can u explain your exact requirement....so tat I can give some other suggestion? Because you cannot stop when timer enabled is false. Because it’s just like another thread
Ok thanks Hariharanmca...
I just want make programm like LOTTRE do u know LOTTRE.. ..mmm to defficult to say...cos my english so poor...
I just 1 winning or 1 value in text1.text from looping run, not all number from 100 to 10000 display on text1.tex.
when i click check box value= 1 then looping on, If check1 box = 0 looping off
this sample:
Private Sub Check1_Click()
If Check1.Value = 1 Then
Timer1.Enabled = True
ElseIf check1.value=0 then
Timer1.Enabled = False
End If
End Sub
Private Sub Form_Load()
timer1.interval=10
End sub
Private Sub Timer1_Timer()
For j = 100 To 10000
DoEvents
Text1.Text = j
Next j
End Sub
this code has correct, the problem is, when looping run
and on text1.text=500 shown i click check1 box to stop looping . and i want the winning is number 500, but value of text1.text always shown 10000. cos looping still run event i click check1 box to put value=0. whay this haven Hariharanmca?
do u have sugesstion?
Ok thanks Hariharanmca...
I just want make programm like LOTRE do u know LOTRE.. ..mmm to defficult to say...cos my english so poor...
I just 1 winning or 1 value in text1.text when looping run, not all number from 100 to 10000 display on text1.tex.
when i click check box value= 1 then looping on, If check1 box = 0 stop looping
this sample:
Private Sub Check1_Click()
If Check1.Value = 1 Then
Timer1.Enabled = True
ElseIf check1.value=0 then
Timer1.Enabled = False
End If
End Sub
Private Sub Form_Load()
timer1.interval=10
End sub
Private Sub Timer1_Timer()
For j = 100 To 10000
DoEvents
Text1.Text = j
Next j
End Sub
this code has correct, the problem is, when looping run
and on text1.text=500 shown i click check1 box to stop looping . and i want the winning is number 500, but value of text1.text always shown 10000. cos looping still run event i click check1 box to put value=0. whay this haven Hariharanmca?
do u have sugesstion?
1 Enable the timer to true in Properties
2.Set the timer interval to 10 or 20 for random speed
take the code below -
Private Sub Timer1_Timer()
-
If Check1.Value = 1 Then
-
For j = 100 To 10000
-
DoEvents
-
Text1.Text = j
-
Next j
-
End if
-
End Sub
(No VB in my system. Code not tested)
I think perhaps you have misunderstood how the timer works. When the timer fires, it will start running the code in your Timer event procedure. From that point on, the time is irrelevant. It just works through the code until it finishes, or gets kicked out of the routine or whatever. So, in this case your code effectively says "if the check box is checked, then go and do all of this". If you want it to do something different along the way, based on the checkbox value, you have to code it that way.
The secret to all this is to learn to think like a computer. In other words, stupid!
I'm serious - computers are completely stupid. They don't do what you want them to do. They do precisely what they are told to do, one step at a time. Where people always go wrong is in trying to think sensibly about their code. Computers are not sensible - they just follow instructions. To understand what your code will do, you have to follow it statement by statement, without jumping to conclusions and making assumptions.
Your code says to count from 100 to 10,000 so that's what it does. There's nothing in there that says to stop, for any reason.
If you want it to stop when you "turn off" the checkbox, I'd say there are two basic approaches you could take: - Do one step each time the timer control fires, if the checkbox is checked.
- Do it all in one go as you have in your original post, but add some code inside the loop to exit if the checkbox is not set. This would be the simpler method to implement, since it's only a small change to your existing code.
1 Enable the timer to true in Properties
2.Set the timer interval to 10 or 20 for random speed
take the code below -
Private Sub Timer1_Timer()
-
If Check1.Value = 1 Then
-
For j = 100 To 10000
-
DoEvents
-
Text1.Text = j
-
Next j
-
End if
-
End Sub
This still suffers from the original problem, which is that you are saying "if the checkbox is checked, do everything. Otherwise, do nothing". What you need to do is stop when the checkbox value changes. See my prior post. (Sorry, it took quite a while to type.)
Yes Killer42...u r correct..
i have put code like
still not work - Private Sub Timer1_Timer()
-
If Check1.Value = 1 Then
-
For j = 100 To 10000
-
DoEvents
-
Text1.Text = j
-
Next j
-
End if
-
End Sub
so whould u give me some code Killer42
to stop loop when i checked=0.
thanks in advance
This still suffers from the original problem, which is that you are saying "if the checkbox is checked, do everything. Otherwise, do nothing". What you need to do is stop when the checkbox value changes. See my prior post. (Sorry, it took quite a while to type.)
-
-
Dim intDisplay as integer
-
-
Private Sub Timer1_Timer()
-
If Check1.Value = 1 Then
-
if intDisplay > 10000 then intDisplay = 99
-
intDisplay = intDisplay + 1
-
Text1.Text = intDisplay
-
End if
-
End Sub
-
-
Private Sub Check1_Click()
-
intDisplay = 100
-
End Sub
(Not Tested)
i think this will work
-
-
Dim intDisplay as integer
-
-
Private Sub Timer1_Timer()
-
If Check1.Value = 1 Then
-
if intDisplay > 10000 then intDisplay = 99
-
intDisplay = intDisplay + 1
-
-
Text1.Text = intDisplay
-
End if
-
End Sub
-
-
Private Sub Check1_Click()
-
intDisplay = 100
-
End Sub
(Not Tested)
i think this will work
my request, i want to know the out put or this code. can any 1 test it and reply
(I don't have VB in my system).
- Private Sub Timer1_Timer()
-
If Check1.Value = 1 Then
-
For j = 100 To 10000
-
DoEvents ' You should swap this line...
-
Text1.Text = j ' ...and this line.
-
Next j
-
End if
-
End Sub
so whould u give me some code Killer42
to stop loop when i checked=0.
Nope. :)
But I'll tell you how you can do it. First of all, I'd recommend reversing the order of the DoEvents and the Text1.Text = j - but that's unrelated.
Inside your loop, just code "if checkbox is not checked, escape from the loop". I'd prefer you do the translation from English to VB. It's fairly straightforward. Hint, you want to Exit from the For loop.
Nope. :)
But I'll tell you how you can do it. First of all, I'd recommend reversing the order of the DoEvents and the Text1.Text = j - but that's unrelated.
Inside your loop, just code "if checkbox is not checked, escape from the loop". I'd prefer you do the translation from English to VB. It's fairly straightforward. Hint, you want to Exit from the For loop.
- Dim intDisplay as integer
-
-
Private Sub Timer1_Timer()
-
If Check1.Value = 1 Then
-
if intDisplay > 10000 then intDisplay = 99
-
intDisplay = intDisplay + 1
-
Text1.Text = intDisplay
-
End if
-
End Sub
-
-
Private Sub Check1_Click()
-
intDisplay = 100
-
End Sub
how about this code
how about this code
Yes, that looks like the other option I mentioned. Incrementing each time the timer event fires. For this you would want a pretty small timer interval.
Yes, that looks like the other option I mentioned. Incrementing each time the timer event fires. For this you would want a pretty small timer interval.
Yha, Whatever I mention above for properties.
is that code working fine?
I haven't had a chance to try it. But it looks alright.
sorry hariharanmca..
not work
when looping run the resul text1.text =1
just it... and stop and looping not run again even check1 value =1
sorry hariharanmca..
not work
when looping run the resul text1.text =1
just it... and stop and looping not run again even check1 value =1
-
Dim intDisplay as integer
-
-
Private Sub Timer1_Timer()
-
If Check1.Value = 1 Then
-
if intDisplay > 10000 then intDisplay = 99
-
intDisplay = intDisplay + 1
-
Text1.Text = intDisplay
-
End if
-
End Sub
-
-
Private Sub Check1_Click()
-
intDisplay = 100
-
End Sub
Try this qode
Sign in to post your reply or Sign up for a free account.
Similar topics
by: ={ Advocated }= |
last post by:
Hi there, im in need to use a loop, im not sure exactly how to do it :S
########################
/*
* File: Payroll.c
* Program to calculate the wage of a user
*/
#include <stdio.h>
int...
|
by: Dr. Zharkov |
last post by:
To see character of Microsoft Agent in Visual Basic .NET 2003, we create the
project: File, New, Project, Visual Basic Project, Windows Application. In
Form1 we place two controls: Button and...
|
by: Dr. Zharkov |
last post by:
To see character of Microsoft Agent in Visual Basic .NET 2003, we create the
project: File, New, Project, Visual Basic Project, Windows Application. In
Form1 we place two controls: Button and...
|
by: Dr. Zharkov |
last post by:
Hello. In project on Visual Basic .NET 2003 (File, New, Project, Visual
Basic Project, Windows Application) after occurrence of Genie of Microsoft
Agent and pressing of key Scroll Lock below Genie...
|
by: james |
last post by:
Hi, I am loading a CSV file ( Comma Seperated Value) into a Richtext box. I have a routine that splits the data up when it hits
the "," and then copies the results into a listbox. The data also...
|
by: Demonicpagan |
last post by:
I have this form where I am trying to place items from checked boxes
into a text box. An image of what this form looks like is at
http://www.stelth2000inc.com/images/screen.png
Here is some...
|
by: XpatienceX |
last post by:
Hi,
Can someone help me with this assignment, I am confused of what is needed to be done here.
I am suposed to design a program that models a worm's behavior in the following scenario:
A...
|
by: =?Utf-8?B?R2Vvcmdl?= |
last post by:
Hello everyone,
Wide character and multi-byte character are two popular encoding schemes on
Windows. And wide character is using unicode encoding scheme. But each time I
feel confused when...
|
by: =?Utf-8?B?TWFyaw==?= |
last post by:
I modified a C# application from Bob Powell that moves graphics primitives
around on the screen into a Vb.NET 2005 application. I want to modify this
application so along with moving regular...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |