Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Grr, encountering really annoying issues.

I am having a bunch of code which i am using to dimension a vessel
filled with water. It can be seen like this:

On the one side I calculate how much the level drops in the vessel in
a time interval (numerical integration).
On the other side I created loads of blue labels, which changes
colours when the vessel is emptying. I am so close to the solution. I
can smell it. But why oo why doesnt it go the way I want it.

The program executes by a commandbutton and click event. I want to
make this completely automatic so you only have to click once!

NOW then.. this is the siuation.

When the code executes. It calculates a value and puts it in a cell.
Then it checks the value and switches the colour of a label. WORKS
GREAT!!!

but it works great everytime I click the button and click the button.
When I click the button 900 times. my vessel is empty.

So this is the code what I came (and help from the
excelprogramminggroupies) with:

I tried it with a Do..Loop event but what happens then is that the
whole thing is calculating, and only check the labels @ the end.

Sub EmptyVessel()

dt = 100
dia_vat = 0.5
Hoogte_vat = 1.2
Pi = 355 / 113
Cd = 0.85
Ag = 0.00002
g = 9.81
x_t_0 = 0
N_0 = 1.2
N_1 = 1
N_2 = 0.75
N_3 = 0.5
N_4 = 0.25

H_0_0 = Application.WorksheetFunction.Max((N_0 - x_t_0), 0)
H_1_0 = Application.WorksheetFunction.Max((N_1 - x_t_0), 0)
H_2_0 = Application.WorksheetFunction.Max((N_2 - x_t_0), 0)
H_3_0 = Application.WorksheetFunction.Max((N_3 - x_t_0), 0)
H_4_0 = Application.WorksheetFunction.Max((N_4 - x_t_0), 0)

Q_0_0 = Cd * Ag * Sqr(2 * g * H_0_0)
Q_1_0 = Cd * Ag * Sqr(2 * g * H_1_0)
Q_2_0 = Cd * Ag * Sqr(2 * g * H_2_0)
Q_3_0 = Cd * Ag * Sqr(2 * g * H_3_0)
Q_4_0 = Cd * Ag * Sqr(2 * g * H_4_0)

q_tot_0 = Q_0_0 + Q_1_0 + Q_2_0 + Q_3_0 + Q_4_0

x_t_t = Cells(13, "B").Value + (q_tot_0 / Pi * ((dia_vat / 2) ^ 2) *
dt)
Cells(14, "B").Value = x_t_t

H_0_t = Application.WorksheetFunction.Max((N_0 - x_t_t), 0)
H_1_t = Application.WorksheetFunction.Max((N_1 - x_t_t), 0)
H_2_t = Application.WorksheetFunction.Max((N_2 - x_t_t), 0)
H_3_t = Application.WorksheetFunction.Max((N_3 - x_t_t), 0)
H_4_t = Application.WorksheetFunction.Max((N_4 - x_t_t), 0)

Q_t_t = (Cd * Ag * Sqr(2 * g * H_0_t)) + (Cd * Ag * Sqr(2 * g *
H_1_t)) + (Cd * Ag * Sqr(2 * g * H_2_t)) + (Cd * Ag * Sqr(2 * g *
H_3_t)) + (Cd * Ag * Sqr(2 * g * H_4_t))

dx = Q_t_t * ((dia_vat / 2) ^ 2) * dt
If x_t_t <= 1.2 Then Cells(13, "B").Value = x_t_t + dx

' the label color check:

Dim y As Integer

For y = 1 To 86
If x_t_t (y / 86) * 1.2 Then
Me.Controls("Label" & CStr(y - 1)).BackColor = vbBlack
Me.Controls("Label" & CStr(y - 1)).BorderColor = vbBlack
End If
Next y

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default Grr, encountering really annoying issues.

Hi
Try
Me.Repaint
after changing the controls.

If that doesn't work try
DoEvents
after changing the controls.
regards
Paul

On Jun 7, 2:56 pm, Robert wrote:
I am having a bunch of code which i am using to dimension a vessel
filled with water. It can be seen like this:

On the one side I calculate how much the level drops in the vessel in
a time interval (numerical integration).
On the other side I created loads of blue labels, which changes
colours when the vessel is emptying. I am so close to the solution. I
can smell it. But why oo why doesnt it go the way I want it.

The program executes by a commandbutton and click event. I want to
make this completely automatic so you only have to click once!

NOW then.. this is the siuation.

When the code executes. It calculates a value and puts it in a cell.
Then it checks the value and switches the colour of a label. WORKS
GREAT!!!

but it works great everytime I click the button and click the button.
When I click the button 900 times. my vessel is empty.

So this is the code what I came (and help from the
excelprogramminggroupies) with:

I tried it with a Do..Loop event but what happens then is that the
whole thing is calculating, and only check the labels @ the end.

Sub EmptyVessel()

dt = 100
dia_vat = 0.5
Hoogte_vat = 1.2
Pi = 355 / 113
Cd = 0.85
Ag = 0.00002
g = 9.81
x_t_0 = 0
N_0 = 1.2
N_1 = 1
N_2 = 0.75
N_3 = 0.5
N_4 = 0.25

H_0_0 = Application.WorksheetFunction.Max((N_0 - x_t_0), 0)
H_1_0 = Application.WorksheetFunction.Max((N_1 - x_t_0), 0)
H_2_0 = Application.WorksheetFunction.Max((N_2 - x_t_0), 0)
H_3_0 = Application.WorksheetFunction.Max((N_3 - x_t_0), 0)
H_4_0 = Application.WorksheetFunction.Max((N_4 - x_t_0), 0)

Q_0_0 = Cd * Ag * Sqr(2 * g * H_0_0)
Q_1_0 = Cd * Ag * Sqr(2 * g * H_1_0)
Q_2_0 = Cd * Ag * Sqr(2 * g * H_2_0)
Q_3_0 = Cd * Ag * Sqr(2 * g * H_3_0)
Q_4_0 = Cd * Ag * Sqr(2 * g * H_4_0)

q_tot_0 = Q_0_0 + Q_1_0 + Q_2_0 + Q_3_0 + Q_4_0

x_t_t = Cells(13, "B").Value + (q_tot_0 / Pi * ((dia_vat / 2) ^ 2) *
dt)
Cells(14, "B").Value = x_t_t

H_0_t = Application.WorksheetFunction.Max((N_0 - x_t_t), 0)
H_1_t = Application.WorksheetFunction.Max((N_1 - x_t_t), 0)
H_2_t = Application.WorksheetFunction.Max((N_2 - x_t_t), 0)
H_3_t = Application.WorksheetFunction.Max((N_3 - x_t_t), 0)
H_4_t = Application.WorksheetFunction.Max((N_4 - x_t_t), 0)

Q_t_t = (Cd * Ag * Sqr(2 * g * H_0_t)) + (Cd * Ag * Sqr(2 * g *
H_1_t)) + (Cd * Ag * Sqr(2 * g * H_2_t)) + (Cd * Ag * Sqr(2 * g *
H_3_t)) + (Cd * Ag * Sqr(2 * g * H_4_t))

dx = Q_t_t * ((dia_vat / 2) ^ 2) * dt
If x_t_t <= 1.2 Then Cells(13, "B").Value = x_t_t + dx

' the label color check:

Dim y As Integer

For y = 1 To 86
If x_t_t (y / 86) * 1.2 Then
Me.Controls("Label" & CStr(y - 1)).BackColor = vbBlack
Me.Controls("Label" & CStr(y - 1)).BorderColor = vbBlack
End If
Next y

End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Grr, encountering really annoying issues.

WOW, OMG!!!

When I tried Me.Repaint my computer totally flipped out!!

However, the DoEvents works PERFECTTT!!!

Thanks friend. You helped me to get on step closer on graduating. =]

Regards,

Robert.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
why am i encountering result N#A when doing the VLOOKUP function Mame Excel Discussion (Misc queries) 2 April 29th 09 09:17 AM
Adding adjacent numbers and resettiing when encountering 0 Midnight404 Excel Worksheet Functions 0 August 5th 05 01:03 PM
Annoying pop up Sam Excel Discussion (Misc queries) 2 July 15th 05 02:08 PM
Annoying web toolbar Kanan Excel Programming 0 March 8th 05 05:49 PM
Annoying bug. Shunt Excel Programming 1 August 7th 03 02:05 PM


All times are GMT +1. The time now is 02:56 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"