473,507 Members | 2,375 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to call and interpolate data from a table?

Mas Juliza Alias
67 New Member
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.
Feb 24 '11 #1
6 2518
Guido Geurs
767 Recognized Expert Contributor
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
Feb 25 '11 #2
Mas Juliza Alias
67 New Member
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
Feb 27 '11 #3
Guido Geurs
767 Recognized Expert Contributor
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:

Expand|Select|Wrap|Line Numbers
  1. ...
  2.    With MSFlexGrid
  3.       LabelMsg.Visible = False
  4.       TextMin.Text = ""
  5.       TextMax.Text = ""
  6.       '§ check minimum
  7.       If Val(TextInput.Text) < .TextMatrix(1, 0) Then
  8.          TextCalc.Text = Format(.TextMatrix(1, 1), "0.000")
  9.          LabelMsg.Caption = "Vallue is less then Minimum !"
  10.          LabelMsg.Visible = True
  11.          Exit Sub
  12.       End If
  13.       '§ check maximum
  14.       If Val(TextInput.Text) > .TextMatrix(.Rows - 1, 0) Then
  15.          TextCalc.Text = Format(.TextMatrix(.Rows - 1, 1), "0.000")
  16.          LabelMsg.Caption = "Vallue is more then Maximum !"
  17.          LabelMsg.Visible = True
  18.          Exit Sub
  19.       End If
  20.       '§ calculate
  21.       For ROWidx = 1 To .Rows - 1
  22. ...
Feb 27 '11 #4
Mas Juliza Alias
67 New Member
There is no volume appear when I enter 1.200 elevation.
Mar 1 '11 #5
Guido Geurs
767 Recognized Expert Contributor
Fahad Ali,

Please make your own call via "Ask Your Question" in the forum "Microsoft Access / VBA"
Mar 1 '11 #6
Guido Geurs
767 Recognized Expert Contributor
Sorry, my mistake.
This is the solution when you enter a value that is equal to a value in the list:

Expand|Select|Wrap|Line Numbers
  1. Private Sub ComCalc_Click()
  2. Dim ROWidx As Integer
  3. Dim ELEVATIONmin As Double
  4. Dim ELEVATIONmax As Double
  5. Dim VOLUMEmin As Double
  6. Dim VOLUMEmax As Double
  7. Dim VOLUMEDIF As Double
  8.    With MSFlexGrid
  9.       LabelMsg.Visible = False
  10.       TextMin.Text = ""
  11.       TextMax.Text = ""
  12.       '§ check minimum
  13.       If Val(TextInput.Text) < Val(.textmatrix(1, 0)) Then
  14.          TextCalc.Text = Format(.textmatrix(1, 1), "0.000")
  15.          LabelMsg.Caption = "Vallue is less then Minimum !"
  16.          LabelMsg.Visible = True
  17.          Exit Sub
  18.       End If
  19.       '§ check maximum
  20.       If Val(TextInput.Text) > Val(.textmatrix(.Rows - 1, 0)) Then
  21.          TextCalc.Text = Format(.textmatrix(.Rows - 1, 1), "0.000")
  22.          LabelMsg.Caption = "Vallue is more then Maximum !"
  23.          LabelMsg.Visible = True
  24.          Exit Sub
  25.       End If
  26.       '§ calculate
  27.       For ROWidx = 1 To .Rows - 1
  28.          If Val(.textmatrix(ROWidx, 0)) = Val(TextInput.Text) Then
  29.             TextCalc.Text = Format(.textmatrix(ROWidx, 1), "0.000")
  30.             Exit Sub
  31.          ElseIf Val(.textmatrix(ROWidx, 0)) > Val(TextInput.Text) Then
  32.             TextMin.Text = .textmatrix(ROWidx - 1, 0)
  33.             TextMax.Text = .textmatrix(ROWidx, 0)
  34.             ELEVATIONmin = Val(.textmatrix(ROWidx - 1, 0))
  35.             ELEVATIONmax = Val(.textmatrix(ROWidx, 0))
  36.             VOLUMEmin = Val(.textmatrix(ROWidx - 1, 1))
  37.             VOLUMEmax = Val(.textmatrix(ROWidx, 1))
  38.             VOLUMEDIF = (VOLUMEmax - VOLUMEmin) * _
  39.                (Val(TextInput.Text) - ELEVATIONmin) / _
  40.                       (ELEVATIONmax - ELEVATIONmin)
  41.             TextCalc.Text = Format(VOLUMEmin + VOLUMEDIF, "0.000")
  42.             Exit Sub
  43.          End If
  44.       Next
  45.    End With
  46. End Sub
Mar 1 '11 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2469
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...
2
2690
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...
11
3425
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...
1
2764
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...
15
2604
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
1
3472
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...
3
2226
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...
2
1260
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...
4
34445
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...
1
2619
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....
0
7223
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,...
0
7319
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,...
0
7376
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...
1
7031
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...
0
7485
tracyyun
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...
0
4702
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
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
760
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
412
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.