473,498 Members | 1,656 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Newbe question, What am I doing wrong

ken
Hi,
I have two questions the first is: in the example below how can I call
an event from within a statement, such as replace Stop1 with cmdStop1
which is a button on my form?
My second question again deals with the example below. Shouldn't I see
the valve of " i" counting away in the txtCount1 text box? I don't
see anything in the text box and would like to know what I'm doing
wrong. Thanks in advance for any and all help.
Regards,
Ken

Stop1 = 0
Do
For i As Integer = 1 To 10
txtCount1.Text = i
If Stop1 = 1 Then
Exit Do
End If
Next i
Loop
End Sub
Jan 21 '06 #1
5 1352
"ken" <so******@out.there> schrieb
Hi,
I have two questions the first is: in the example below how can I
call an event from within a statement, such as replace Stop1 with
cmdStop1 which is a button on my form?
You can not call an event. Either /raise/ an event or /handle/ it.
My second question again deals with the example below. Shouldn't I
see the valve of " i" counting away in the txtCount1 text box? I
don't see anything in the text box and would like to know what I'm
doing wrong. Thanks in advance for any and all help.
Regards,
Ken

Stop1 = 0
Do
For i As Integer = 1 To 10
txtCount1.Text = i
If Stop1 = 1 Then
Exit Do
End If
Next i
Loop
End Sub

The textbox doesn't update because there is no time. There is not time
because the loop is running. If you update a control, the rectangle on the
screen is added to a list of invalid areas. The screen is (usually) not
updated immediatelly. As soon as there is time, Win sends a message to the
control (called WM_PAINT). Whenever the control receives this messages, it
paints itself. The message can not be handled before your sub returns.

To update the control immediatelly, call it's refresh method:
txtcount1.refresh. This /forces/ the immediate repaint of the control.

Be aware of a problem existing in WinXP (3rd paragraph):
http://msdn.microsoft.com/library/en...sagequeues.asp

This means, even in a tiny program, you are forced to use a second thread to
run the loop (or use application.doevents with all it's side-effects). A
work-around is to call the API function Peekmessage within the loop (in
addition to calling refresh).
Armin

Jan 21 '06 #2
ken
Armin,
Thank you for answering my questions. I suspected that loop was
happening to fast to update. Once again thanks.
Ken
Jan 21 '06 #3
Button1.PerformClick
--
Dennis in Houston
"ken" wrote:
Armin,
Thank you for answering my questions. I suspected that loop was
happening to fast to update. Once again thanks.
Ken

Jan 21 '06 #4
ken
Hi Dennis and thanks, What I was trying to say is how can I check if a
Button has been Clicked from within a Loop.
Ken
Jan 22 '06 #5
For one thing, the button Click event won't fire until your loop finishes
unless you have a "DoEvents" statement within your loop or the loop is
executing on a NON-UI thread.

If you put a "DoEVents" statement withing your loop, you can use a boolean
variable which scoped for access both in the button click event handler and
the loop. Set the variable to False before the loop starts then set it to
true in the button click event handler and check it after the DoEvents
Statement in your loop.

Hope this helps.
--
Dennis in Houston
"ken" wrote:
Hi Dennis and thanks, What I was trying to say is how can I check if a
Button has been Clicked from within a Loop.
Ken

Jan 22 '06 #6

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

Similar topics

2
1487
by: splatter | last post by:
Hey all, I'm trying to get a java bookmark to work from my browsers address field which is supposed to send a prefix + reload the current page from my proxy & return a special view depending on...
9
6659
by: Yaro | last post by:
Hello DB2/NT 8.1.3 Sorry for stupid questions. I am newbe in DB2. 1. How can I read *.sql script (with table and function definitions) into a database? Tool, command... 2. In Project Center...
1
1991
by: Jim | last post by:
I have created a windows form that contains several tab pages which contain a panels. On a tab page I am trying to dynamically create a series of buttons in that pages panel. I am failing because...
2
1091
by: fizgig | last post by:
Hi all, I've been meaning to ask this for a long time, but my computer has been down more then has been up, but my question is when I bought Microsoft Visual C#.NET Standard 2003 Edition I also...
19
1529
by: AMP | last post by:
I have a simple question. If i have a button on form1 that creates : Form2 newform = new Form2(); newform.Show(); As I click the button a new form shows,but acording to my code each one has...
2
2523
by: ken | last post by:
Hello everyone, I'm new to visual VB and I am trying to setup communications using the Function ReceiveSerialData() As String example found in the help section of Microsoft Visual Basic 2005...
17
2681
by: Eric_Dexter | last post by:
def simplecsdtoorc(filename): file = open(filename,"r") alllines = file.read_until("</CsInstruments>") pattern1 = re.compile("</") orcfilename = filename + "orc" for line in alllines: if not...
13
1699
by: Eric_Dexter | last post by:
All I am after realy is to change this reline = re.line.split('instr', '/d$') into something that grabs any line with instr in it take all the numbers and then grab any comment that may or may...
5
1915
by: troy | last post by:
Could someone please point me in the right direction on how to read in a large query with .net. I am trying to emulate a legacy database system so I don't know the upper bounds of the sql query....
0
7205
jinu1996
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...
0
5462
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4910
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4590
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3093
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1419
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
291
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.