473,385 Members | 2,003 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Calculate numbers from MSFlexGrid

Mas Juliza Alias
I am developing a program of an information system for reservoir operation. I have a table, MSFlexGrid1 with 4 columns of Initial Depth, End Depth, Cut Volume, and Fill Volume (see attachment 'a.jpg'). There is a button 'Calculate' next to the table which whenever user clicks the button another form containing another MSFlexGrid table will appear. This table contains 2 columns which are Depth and Cumulative Volume (see attachment 'b.jpg'). Cumulative Volume is the sum of Cut Volume and/or Fill Volume at each Depth. So far i have this code from a helpful friend in Bytes, but somehow it sums only the Cut Volume (CUTVOL).
Expand|Select|Wrap|Line Numbers
  1.       For ARRAYDATAidx = 2 To UBound(ARRAYDATA) '§ loop trough the ARRAYDATA and add each line in the MSFlexGrid1
  2.          MSFlexGrid1.AddItem ARRAYDATA(ARRAYDATAidx).DEPTH1 & vbTab & _
  3.             CStr(Format(CSng(ARRAYDATA(ARRAYDATAidx - 1).CUTVOL) + _
  4.             CSng(.TextMatrix(ARRAYDATAidx - 1, 1)), "#.0"))
  5.       Next
how can i modify this code to make it calculate both CUTVOL and FILLVOL?
Attached Images
File Type: jpg a.jpg (60.0 KB, 797 views)
File Type: jpg b.jpg (25.5 KB, 604 views)
Dec 16 '10 #1

✓ answered by Guido Geurs

Hey,
If its Cutvol AND (or) fillvol then its:
Expand|Select|Wrap|Line Numbers
  1.       For ARRAYDATAidx = 2 To UBound(ARRAYDATA) '§ loop trough the ARRAYDATA and add each line in the MSFlexGrid1
  2.          If ARRAYDATA(ARRAYDATAidx - 1).CUTVOL <> "" Then
  3.             MSFlexGrid1.AddItem ARRAYDATA(ARRAYDATAidx).DEPTH1 & vbTab & _
  4.                CStr(Format(CSng(ARRAYDATA(ARRAYDATAidx - 1).CUTVOL) + _
  5.                CSng(.TextMatrix(ARRAYDATAidx - 1, 1)), "#.0"))
  6.          Else
  7.             MSFlexGrid1.AddItem ARRAYDATA(ARRAYDATAidx).DEPTH1 & vbTab & _
  8.                CStr(Format(CSng(ARRAYDATA(ARRAYDATAidx - 1).FILLVOL) + _
  9.                CSng(.TextMatrix(ARRAYDATAidx - 1, 1)), "#.0"))
  10.          End If
  11.       Next

2 3067
Guido Geurs
767 Expert 512MB
Hey,
If its Cutvol AND (or) fillvol then its:
Expand|Select|Wrap|Line Numbers
  1.       For ARRAYDATAidx = 2 To UBound(ARRAYDATA) '§ loop trough the ARRAYDATA and add each line in the MSFlexGrid1
  2.          If ARRAYDATA(ARRAYDATAidx - 1).CUTVOL <> "" Then
  3.             MSFlexGrid1.AddItem ARRAYDATA(ARRAYDATAidx).DEPTH1 & vbTab & _
  4.                CStr(Format(CSng(ARRAYDATA(ARRAYDATAidx - 1).CUTVOL) + _
  5.                CSng(.TextMatrix(ARRAYDATAidx - 1, 1)), "#.0"))
  6.          Else
  7.             MSFlexGrid1.AddItem ARRAYDATA(ARRAYDATAidx).DEPTH1 & vbTab & _
  8.                CStr(Format(CSng(ARRAYDATA(ARRAYDATAidx - 1).FILLVOL) + _
  9.                CSng(.TextMatrix(ARRAYDATAidx - 1, 1)), "#.0"))
  10.          End If
  11.       Next
Attached Images
File Type: gif Cal_v6.1.0.GIF (6.8 KB, 536 views)
Dec 16 '10 #2
THANKS! that works nicely. I've learnt a lot from your code. Thank YOU! :)
Dec 17 '10 #3

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

Similar topics

9
by: Vjay77 | last post by:
I am working on the program where is necessary to calculate huge amount of numbers in always the same sequence. In other words, these number have to be calculated and saved into memory before the...
0
by: Martin K | last post by:
Hello all..thanks for everyone's advice regarding my SHBrowseForFolder API problem, I was able to put together a public class that runs great! But I have another migration headache regarding the...
1
by: Mad Scientist Jr | last post by:
can someone explain how to simply populate a grid in .net ? the way i understand it, there is no more msflexgrid, and instead is this new control that has to be tied to a dataset, and it is a real...
33
by: patrick_woflian | last post by:
hey guys, im just writing a basic calculation at the moment, before building on it for an A-Level piece of work. i can add/divide etc... two numbers together yet i am having a major problem with...
2
by: Gilbert Röhrbein | last post by:
Hi coders, I want to calculate big prime numbers. To test if a number is prime i want to use the Miller-Rabin-Algo, but the calculation of "2^x" (for x > 1023) isn't possible with datatypes like...
4
by: uprakash14 | last post by:
i have import excel data in MSflexgrid.. Now i want to count the data for particulars fields... Like Data have four column A, B, C and D while using A column, i have to calculate the data of B...
1
by: vinod kumar sharma | last post by:
I have the problem of how to calculate the values shown in the cols of MSFLexgrid in vb6. PLease send the coding with logic on my e mail address at the earliest with thanks vinod kumar sharma
0
by: MiziaQ | last post by:
Hey, I'm using the following code to filter an msflexgrid to only display rows with the entry "East Cork" in the 8th column. The table has many more entries, so, when I run the application, many...
2
by: new | last post by:
Hello I am using the following to calculate the number of visible lines in a listbox. This works, but when I add a horizontal scroll bar it does not work correctly. How can I subtract the size of...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...

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.