hi,
I am currently developing a program that contains a table with two columns: 1)Elevation 2)Volume.
There is also a graph of Elevation vs Volume next to the table. 2 text boxes have been placed at the bottom of the graph so that user can enter a value of elevation at textbox1, and the program will call the volume at that elevation from the table and displays it in textbox2. Another concern is on the interpolation of the volume data from the table, if the elevation entered by user is in between the range of elevation in the table, for example
Data in table:
Elevation | Volume
1.000 | 50.000
1.100 | 60.000
1.200 | 70.500
Elevation entered by user: 1.156
Volume difference = (70.500-60.000)*[(1.156-1.100)/(1.200-1.100)] = 5.88
Hence, volume at 1.156 = 60.000 + Volume difference = 60.588
How to code to read the data in the table and apply the above formula to get the volume at the elevation as entered by user?
Thank you in advance.
6 2518
Run through the list and when the value in the list > input then the top = value in list and bottom = value with (index-1).
See attachment for code
PS:
Must it not be 65.88 ?
Volume difference = (70.500-60.000)*[(1.156-1.100)/(1.200-1.100)] = 5.88
Hence, volume at 1.156 = 60.000 + Volume difference = 65.88
You are such an EXPERT! I have applied the code in my program and it works nicely.
However there is one thing that I want to modify but I don't know how. If I enter the highest value, 1.200, and click the Calculate button, the volume does not appear. How to code so that it will appear like we enter the other values of elevation?
Thank YOU
Check Min. and Max. value in the grid with next code (see attachment):
Q1: what do you mean with "like we enter the other values of elevation" ?
Is it: when it's less then then Min value in the grid, show the min value for the volume and when it's more then the Max value, show the max volume ?
If so, this is the code: - ...
-
With MSFlexGrid
-
LabelMsg.Visible = False
-
TextMin.Text = ""
-
TextMax.Text = ""
-
'§ check minimum
-
If Val(TextInput.Text) < .TextMatrix(1, 0) Then
-
TextCalc.Text = Format(.TextMatrix(1, 1), "0.000")
-
LabelMsg.Caption = "Vallue is less then Minimum !"
-
LabelMsg.Visible = True
-
Exit Sub
-
End If
-
'§ check maximum
-
If Val(TextInput.Text) > .TextMatrix(.Rows - 1, 0) Then
-
TextCalc.Text = Format(.TextMatrix(.Rows - 1, 1), "0.000")
-
LabelMsg.Caption = "Vallue is more then Maximum !"
-
LabelMsg.Visible = True
-
Exit Sub
-
End If
-
'§ calculate
-
For ROWidx = 1 To .Rows - 1
-
...
There is no volume appear when I enter 1.200 elevation.
Fahad Ali,
Please make your own call via "Ask Your Question" in the forum "Microsoft Access / VBA"
Sorry, my mistake.
This is the solution when you enter a value that is equal to a value in the list: - Private Sub ComCalc_Click()
-
Dim ROWidx As Integer
-
Dim ELEVATIONmin As Double
-
Dim ELEVATIONmax As Double
-
Dim VOLUMEmin As Double
-
Dim VOLUMEmax As Double
-
Dim VOLUMEDIF As Double
-
With MSFlexGrid
-
LabelMsg.Visible = False
-
TextMin.Text = ""
-
TextMax.Text = ""
-
'§ check minimum
-
If Val(TextInput.Text) < Val(.textmatrix(1, 0)) Then
-
TextCalc.Text = Format(.textmatrix(1, 1), "0.000")
-
LabelMsg.Caption = "Vallue is less then Minimum !"
-
LabelMsg.Visible = True
-
Exit Sub
-
End If
-
'§ check maximum
-
If Val(TextInput.Text) > Val(.textmatrix(.Rows - 1, 0)) Then
-
TextCalc.Text = Format(.textmatrix(.Rows - 1, 1), "0.000")
-
LabelMsg.Caption = "Vallue is more then Maximum !"
-
LabelMsg.Visible = True
-
Exit Sub
-
End If
-
'§ calculate
-
For ROWidx = 1 To .Rows - 1
-
If Val(.textmatrix(ROWidx, 0)) = Val(TextInput.Text) Then
-
TextCalc.Text = Format(.textmatrix(ROWidx, 1), "0.000")
-
Exit Sub
-
ElseIf Val(.textmatrix(ROWidx, 0)) > Val(TextInput.Text) Then
-
TextMin.Text = .textmatrix(ROWidx - 1, 0)
-
TextMax.Text = .textmatrix(ROWidx, 0)
-
ELEVATIONmin = Val(.textmatrix(ROWidx - 1, 0))
-
ELEVATIONmax = Val(.textmatrix(ROWidx, 0))
-
VOLUMEmin = Val(.textmatrix(ROWidx - 1, 1))
-
VOLUMEmax = Val(.textmatrix(ROWidx, 1))
-
VOLUMEDIF = (VOLUMEmax - VOLUMEmin) * _
-
(Val(TextInput.Text) - ELEVATIONmin) / _
-
(ELEVATIONmax - ELEVATIONmin)
-
TextCalc.Text = Format(VOLUMEmin + VOLUMEDIF, "0.000")
-
Exit Sub
-
End If
-
Next
-
End With
-
End Sub
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Kevin Myers |
last post by:
Hello,
I'm an experienced application developer in some languages (including
various SQL dialects), but have very little experience with MS Access or
VBA, and am having trouble figuring out how...
|
by: Brian Mitchell |
last post by:
Ok, I know this is an elementary question but I have a data grid that is
bound to a data table and I can't seem to find a way to match the selected
row in the grid with it's respective row in the...
|
by: Ron L |
last post by:
I have a data table that lists a series of items in my database. In my user
form, I want the user to be able to filter by a number of criteria (e.g.
location, contract, date modified, etc). Other...
|
by: John |
last post by:
Hi
When using Table Adapter Configuration Wizard if 'Use SQL Statements' is
selected as Command Type, the data table's name in dataset is retained and
only its data adapter's select statements...
|
by: Geagleeye |
last post by:
Hi.
I need to interpolate som data i have in my tabel.
my tabel looks like this.
Y X
0
0 0,026
0,037
0,003 0,038
0,005 0,064
| |
by: laredotornado |
last post by:
Hi,
I have a data table on my page (buried amidst other images and
extraneous text). I would like to spawn a new window that
automatically prints the content of my data table, and only that...
|
by: Ctal |
last post by:
I have an app that populates several data tables on load. Each of
these are bound to a datagrid. Above each datagrid I have several
text boxes that display the data for the active row. There are...
|
by: joel |
last post by:
Hi Guys ... I need some help on this... i know i've followed the right
declarations on this.. or if not i may be close on hitting it. And i
know there's something wrong with this code.
This is...
|
by: indona |
last post by:
hi, i have to enter data from a delimited file into sqlserver database table.
i have been able to delimit the file and read the data into a data table, now i want enter the data table contents to...
|
by: BaseballGraphs |
last post by:
Hello,
I am trying to divide one value from my data table with an associated ID by another value from my data table with a different ID for the same day that the value was added to the data table....
|
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,...
| |
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |