473,769 Members | 5,724 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DoEvents resetting variables

Tym
Made the change from vb6 to vb.net and have found that DoEvents()
doesn't work!!

Well, the replacement

System.Windows. Forms.Applicati on.DoEvents()

is causing hell!!

I have a loop such as

for X = 1 to 10
do some things
Next x
System.Windows. Forms.Applicati on.DoEvents()

and the DoEvents command resets the variables and the loop starts all
over again!

What the hell is going on??? I've noticed this a few times,
System.Windows. Forms.Applicati on.DoEvents()
actually causes variables to revert to old values....

Nov 21 '05 #1
7 1888
Do you really need to be using DoEvents()? Try removing the DoEvents calls.
I could help you better if you provided a more detailed code sample.

Regards,
Phil Harvey

"Tym" <no*@any.time > wrote in message
news:k0******** *************** *********@4ax.c om...
Made the change from vb6 to vb.net and have found that DoEvents()
doesn't work!!

Well, the replacement

System.Windows. Forms.Applicati on.DoEvents()

is causing hell!!

I have a loop such as

for X = 1 to 10
do some things
Next x
System.Windows. Forms.Applicati on.DoEvents()

and the DoEvents command resets the variables and the loop starts all
over again!

What the hell is going on??? I've noticed this a few times,
System.Windows. Forms.Applicati on.DoEvents()
actually causes variables to revert to old values....

Nov 21 '05 #2
Tym,
Well, the replacement

System.Windows. Forms.Applicati on.DoEvents()

is causing hell!!


One of the situatons I know that this can be is when your method is actualy
an event what is done and by that starting the same event method again new.

And exactly as well as I call it causing a "Hell" because you loose all
control.

:-)

Cor
Nov 21 '05 #3
Tym
On Wed, 1 Dec 2004 10:05:30 -0000, "Phil Harvey" <ph***@teamlink .it>
wrote:
Do you really need to be using DoEvents()? Try removing the DoEvents calls.
I could help you better if you provided a more detailed code sample.


I tend to use them when the display need "updating". Question is, this
never happed in vb6, so why does it happen in dotnet?
Friend Sub Populate_Cells( )
Dim iCurrentPeriod As Integer
Dim iPeriodCount As Integer
Dim iPerInc As Integer

Me.Text = sSURNAME & ", " & sFORENAME & " " & sMIDDLE
Me.txtName.Text = sSURNAME & ", " & sFORENAME & " " & sMIDDLE
Me.txtFORM.Text = sFORM

If sMIDDLE = "" Then
dROp = dsPUPILS.Tables (0).Select("SUR NAME = '" & sSURNAME
& "'AND FORENAME = '" & sFORENAME & "'")(0)
Else
dROp = dsPUPILS.Tables (0).Select("SUR NAME = '" & sSURNAME
& "'AND FORENAME = '" & sFORENAME & "' AND MIDDLE = '" & sMIDDLE &
"'")(0)
End If

For dayINDEX = 1 To iNoDays
Select Case dayINDEX
Case 1
iPeriodCount = iMonN
Case 2
iPeriodCount = iTueN
Case 3
iPeriodCount = iWedN
Case 4
iPeriodCount = iThuN
Case 5
iPeriodCount = iFriN
Case 6
If iSatN <> 0 Then
iPeriodCount = iSatN
End If
End Select
iPerInc = 1
For periodINDEX = 1 To iPeriodCount
txtDISPLAY(dayI NDEX, periodINDEX).Ba ckColor =
System.Drawing. SystemColors.Wi ndow
If dayINDEX = Weekday(Now) Then
If dtTIMES(dayINDE X, periodINDEX) <
CDate(TimeStrin g) Then
iCurrentPeriod = periodINDEX
End If
End If
'search through the BREAKS table to see if the current
period is a break
dRO = dsBREAKS.Tables (0).Select("PER IOD = " &
periodINDEX)
If dRO.GetUpperBou nd(0) < 0 Then ' not a break - add
the field
sCrit = dROp("P" & dayINDEX.ToStri ng &
(Format(iPerInc , "00").ToString) )
txtDISPLAY(dayI NDEX, periodINDEX).Te xt = sCrit
iPerInc += 1
Else
'it is a break - Populate with break type
For Each Row In dRO
If Row(1) = "B" Then
txtDISPLAY(dayI NDEX, periodINDEX).Te xt =
"BREAK"
ElseIf Row(1) = "L" Then
txtDISPLAY(dayI NDEX, periodINDEX).Te xt =
"LUNCH"
ElseIf Row(1) = "R" Then
txtDISPLAY(dayI NDEX, periodINDEX).Te xt =
"REGISTRATI ON"
End If
Next
End If
System.Windows. Forms.Applicati on.DoEvents()
Next periodINDEX
Next dayINDEX

txtDISPLAY(Week day(Now) - 1, iCurrentPeriod) .BackColor =
System.Drawing. Color.Yellow
Call LockCells()
End Sub

Nov 21 '05 #4
"Tym" <no*@any.time > schrieb:
I have a loop such as

for X = 1 to 10
do some things
Next x
System.Windows. Forms.Applicati on.DoEvents()

and the DoEvents command resets the variables and the loop starts all
over again!


Is the code above the same as you use in your project? 'DoEvents' will be
called /after/ the loop was executed, so I don't see a problem here.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #5
Tym
On Wed, 1 Dec 2004 12:32:00 +0100, "Herfried K. Wagner [MVP]"
<hi************ ***@gmx.at> wrote:
Is the code above the same as you use in your project? 'DoEvents' will be
called /after/ the loop was executed, so I don't see a problem here.


I know - that's what I thought - but it does!!!!

~bangs head on desk~

Forget it guys.... I think I've just realised what happens..... I have
a timer on another for run this routine. When debugging, it just keeps
cycling round - because the timer keeps running it

~embarrassing shade of beetroot~
Sorry guys!!!!

~Ahem~

~wanders off nonchalantly into the sunset, whistling~

Nov 21 '05 #6
Tym,
Forget it guys.... I think I've just realised what happens..... I have
a timer on another for run this routine. When debugging, it just keeps
cycling round - because the timer keeps running it


That is almost the same as I wrote did you not read that?

Cor
Nov 21 '05 #7
Tym
On Wed, 1 Dec 2004 13:41:14 +0100, "Cor Ligthert"
<no************ @planet.nl> wrote:
That is almost the same as I wrote did you not read that?


Yes, thanks - that what got me thinking...
Nov 21 '05 #8

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

Similar topics

4
4842
by: lee | last post by:
I wont to reset all the variables in a c# object at run time, I was hoping for a field collection or some similar method of iterating through the variables. Any ideas ??? -- Lee.
3
4789
by: dotNETDavid | last post by:
We've broken our app into various assemblies. The WinForm assembly provides the user interface, other assemblies provide various I/O services. I'd like to be able to call System.Windows.Forms.Application.DoEvents from within a dll, but it isn't allowed. I don't want to link the dll to our WinForm exe which can call DoEvents. Is there some way to call DoEvents from within a dll? Thanks.
6
4299
by: Ollie Riches | last post by:
I understand the use of Application.DoEvents() to process all outstanding messages on the message queue in a winforms application if you have long running process on the UI thread. But can anyone explain to me why I need to call DoEvents when I am using a COM component that calls back to into the ..Net application? - If I don't call DoEvents after receiving a callback then sometimes no more messages are pumped, it appears that the message...
4
1891
by: Israel Ordonez Jr | last post by:
Hi everybody, I am having a problem with an ASP.NET application i am working on. I new to ASP.NET so I'm not sure if I'm doing this right. I am working on a website that has an oil price listed throught several pages. In the global.asax file i have the following code. Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs) ' Fires when the application is started
17
2399
by: Lance | last post by:
I've noticed that calling DoEvents is much slower in an application that has called Application.EnableVisualStyles in Sub Main. Furthermore, the performance seems to worsen each time that DoEvents is called. To demonstrate what I'm experiencing, create an app with a Sub Main, a Main Form, and a Button (called Button1). Include the following code in Sub Main: Application.EnableVisualStyles Application.DoEvents Application.Run(New...
12
4142
by: Jack Russell | last post by:
My unstanding of all VB up to and including vb6 is that an event could not "interrupt" itself. For instance if you had a timer event containing a msgbox then you would only get one message. However in vb.net you get continual messages (even setting the system modal property). Firstly, are these two assumptions right and if so what is the approved
8
6508
by: TrtnJohn | last post by:
I have an application where I would like to block waiting on an asynchronous event and still process messages. I can implement a hard loop to block such as: Do While StillWaiting Application.DoEvents Loop In this case the asynchronous thread can just set StillWaiting=False when complete.
3
1480
by: CBKowitz | last post by:
Has anyone encountered this problem? I start debugging my application and the session get reset (as far as I can tell). I then stop and restart and everything is fine. Basically the symptoms are as follows: after starting the application, everything is fine and the session variables are set. I get to my 'main' page and click on a button to search or go to another page and the application crashes because the session variables contain...
4
4084
by: Ian Davies | last post by:
Hello I am struggling for a solution to clear some fields on my webpage that takes their values from some sessions My solution below works when the button is clicked twice. I sort of know why I have to click it twice to do the job (the first submit resets the sessions but this it too late to change the field values, which requires another submit to pick up the new session values). Problem is I cant think how to accomplish the resetting of...
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10211
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10045
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7408
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6673
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3958
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 we have to send another system
3
2815
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.