alkc
02-14-2008, 01:20 PM
Hello all
I need some help with fixing a function that isn't working:confused:
I am an Engineer and not a Programmer but have been learning VB6 and will appreciate any help with this.
I have 3 listboxes that are labelled as follow
+ 1st "Number of items" - must be populated from 1 to 30
+ 2nd "H2" - A value that I start with and increase by 0.5 until I complete 30 trials
+ 3rd "P" - A value the needs calculating from the equation below
P = ((H1 * a2) - (d * H2)) / a1
I have the values of "a1", "a2", "H1" and "d" that are in textboxes
I need to assume a starting value for H2 then increase H2 incrementally by 0.5 untill I do 30 iterations
I tried to do write the few lines below but I only succeeded in populating is the first listbox from 1 to 30
The errors I am having:
- the second listbox only adds the first value and repeate the same value for 30 times but fail to add 0.5 to each H2 value
- the third listbox only calculate the P from the equation and repeat the same number for 30 times
Here is my code
Public Function el_us()
Dim P As Currency
Dim a1 As Currency
Dim a2 As Currency
Dim H1 As Currency
Dim H2 As Currency
Dim sa As Currency
Dim denliq As Currency
Dim denmix As Currency
Dim N As Long
Dim no As Long
Dim i As Long
Dim ni As Long
Dim No_of_iterations As Long
H3 = Text1.Text
sa = Text2.Text
denliq = Text3.Text
denmix = Text4.Text
a1 = sa * 14
a2 = denliq - denmix
H2 = Text5.Text
H1 = H3 - H2
N = 0.5 'This is the number that I want to increase H2 by
No_of_iterations = 30
'will need to use the starting value for H2 from Text5.Text to calculate P and increase H2 by 0.5 until it reaches the 30 trials.
For i = 0 To No_of_iterations
For ni = 0 To N
no = 0
dP = ((H1 * a2) - (denmix * (H2 + ni))) / a1
List1.AddItem (no + i)
List2.AddItem (H2 + ni)
List3.AddItem (dP)
Next ni
Next i
End Function
Could any one help me,
Thanks
I need some help with fixing a function that isn't working:confused:
I am an Engineer and not a Programmer but have been learning VB6 and will appreciate any help with this.
I have 3 listboxes that are labelled as follow
+ 1st "Number of items" - must be populated from 1 to 30
+ 2nd "H2" - A value that I start with and increase by 0.5 until I complete 30 trials
+ 3rd "P" - A value the needs calculating from the equation below
P = ((H1 * a2) - (d * H2)) / a1
I have the values of "a1", "a2", "H1" and "d" that are in textboxes
I need to assume a starting value for H2 then increase H2 incrementally by 0.5 untill I do 30 iterations
I tried to do write the few lines below but I only succeeded in populating is the first listbox from 1 to 30
The errors I am having:
- the second listbox only adds the first value and repeate the same value for 30 times but fail to add 0.5 to each H2 value
- the third listbox only calculate the P from the equation and repeat the same number for 30 times
Here is my code
Public Function el_us()
Dim P As Currency
Dim a1 As Currency
Dim a2 As Currency
Dim H1 As Currency
Dim H2 As Currency
Dim sa As Currency
Dim denliq As Currency
Dim denmix As Currency
Dim N As Long
Dim no As Long
Dim i As Long
Dim ni As Long
Dim No_of_iterations As Long
H3 = Text1.Text
sa = Text2.Text
denliq = Text3.Text
denmix = Text4.Text
a1 = sa * 14
a2 = denliq - denmix
H2 = Text5.Text
H1 = H3 - H2
N = 0.5 'This is the number that I want to increase H2 by
No_of_iterations = 30
'will need to use the starting value for H2 from Text5.Text to calculate P and increase H2 by 0.5 until it reaches the 30 trials.
For i = 0 To No_of_iterations
For ni = 0 To N
no = 0
dP = ((H1 * a2) - (denmix * (H2 + ni))) / a1
List1.AddItem (no + i)
List2.AddItem (H2 + ni)
List3.AddItem (dP)
Next ni
Next i
End Function
Could any one help me,
Thanks