Google Answers Logo
View Question
 
Q: Visual Basic 6.0 Program/Code for a Data Calculating Program ( Answered,   3 Comments )
Question  
Subject: Visual Basic 6.0 Program/Code for a Data Calculating Program
Category: Computers > Programming
Asked by: kristalys-ga
List Price: $200.00
Posted: 22 Aug 2005 11:07 PDT
Expires: 21 Sep 2005 11:07 PDT
Question ID: 558788
I do calculations manually at work for the data I get out of the
machine I work with.  However, it gets pretty tedious and I feel it
would be a lot more efficient/productive if I somehow made a program to do the
calculations for me.  I have visual basic 6.0 at work, and have maybe
used it once or twice, so I know a few basic things.  But what I want
to do with it now is make a program that when I open the standalone
application, it will allow me (the user) to click a button that will 
(1)display the sums of 0th file 
(2)display the sums of the 15th file 
(3)display the quotient of 0th file/15th file.  
I have somehow summarized the steps I go through with each file, if
you have any further questions please don?t hesitate to contact me. 
Part 1 is the basic
first part of the program I would like to somehow make, and it shows
the mathematical calculations I usually do by hand behind it.

Part 1
When the user clicks the "calculate parameters" button, behind the
scenes, the program will... go and find/open/analyze the following
folder/files...
We have a folder located in C:/ named ?pl? it holds many files.  Each
of these files is data collected from the machine, and each file is
named 00001.master, 00002.master, 00003.master, etc?  by the machine
for however many files of data is taken from the reading in 15
seconds.  These files data types are ?transmission? (or so it is
labeled by the computer) and are labeled as mentioned above
?00001.master? etc, which are digital files representing a graph.

In each file, we have lots of numbers and the first 16 lines of text
in each file are just a summary the machine gives of what parameters
were on or off, (not necessary for this calculation), then begins the
2 columns of data we will be looking at.  The first column is a bunch
of numbers that pretty much remain static, sometimes we have about 600
numbers in this column, sometimes we have  about 900, but all we need
are a select few numbers between 380 and 780 (for this example let?s
just say we need 380, 400, 520, 630, and 780, although there are a
whole lot more and they don?t follow any sequence, but these numbers
do not change for each file and always appear in each file and we will
need them for each).  You can kind of think of the first column as a
?placeholder? or a key/i.d. field.

In the folder, we pick out the 0th and the 15th files (they will not
always say 00000.master or 00015.master because sometimes the gets
more than 15 files ? since it collects data and creates files for 15
seconds). We will perform the following calculation on these two
files.

First we look at what we are given in the file.  For example? this is
sort of how one transmission file would look like

00000.master (the 0th file)
Date 8-22-05
Machine 1
Serial number 123555
Graph 235235
Blah
Blah blah
And some more data for about 16 lines?
>>>>begin data<<<<
130 		23
135		26.34
199		4
380		0
399		-2
400		-35
430.2		9
440		1.55
490.35		-3.3
500		234
519.4		425
520		6
550.4		-243
600		53
630		-9
648		10
780		22

For ease of reading this, let?s name the first column W, and the
second column %t.

We then go to another file called CF that has a bunch of numbers that
correspond to the numbers for W, i.e. if W = 380, then CF=0; W=400,
CF=.0005; etc?

We need to take the numbers we pulled out for file 0, the 380, 400,
etc, and multiply the respective %t with the CF, so %t*CF=x for 380,
then do this with 400, 520, 630, 780.  once you have found all the
products for each one, you add the products up and this gives you the
sum for the file.

For example?

W	%t	CF		products of %t*CF
380	0	0		0
400	-35	.0005		-.0175
520	6	7.04		42.24
630	-9	2.0889		-18.8001
780	22	0		0

Sum of all products for 0th file = 0+(-.0175)+42.24+(-18.8001)+0 = 23.4224

Repeat what we just did for this file 0 with the 15th file of this folder.  

For the 15th file, we will probably have more or less data numbers in
the file, but we will always have the 380, 400, 520, 630, 780, which
we will take out and find the %t*CF.  The %t is going to be different,
but the CF will be the same (0, .0005, 7.04, 2.0889, 0).  So we will
again find the products of %t*CF, and find the sum of all products for
this 15th file.

Then we will find the quotient of the 0th file/15th file.  

When we first hit the button the first time around in the beginning
when the program started , it should go through all these steps and
then display with labels?

(1)	the sum of products for the 0th file is: 23.4224
(2)	the sum of products for the 15th file is: 25 (or whatever it is, I
just randomly stuck in this number to use as an example, so assume
this is the number for this particular run)
(3)	the quotient of the 0th file/15th file is: .93690 (rounded 5 decimal places) 

if anyone could somehow come up with a VB 6.0 program to do this, this
would make my life a heck of a lot easier.  At the moment I?m trying to
think of how to create this but i?m pretty stuck on just reading the
basic VB primer books, and my pages of calculations are piling up.  i
would like to know the behind the scenes sourcecode to this too, so I
may be able to figure out how this was made and learn a thing or two,
and also so I can add all the numbers I actually go through for this
process, as well as change some numbers if needed.  Thanks!  Your help
is much appreciated! ~k.

Request for Question Clarification by theta-ga on 22 Aug 2005 20:37 PDT
Hi kristalys-ga,
  I have started work on the VB application you require. However, I
need the following clarifications before the application can be
completed:
   - In the question you say that we need to process the 0th and the
15th file. However, you then go on to say that these files may not be
named 0000.master and 0015.master as expected. How then can the
application identify the required files, if not by name?
    - Alternatively, would it be acceptable if the application asked
the user to manually select the 0th and the 15th file?
    - Also, from your description of the CF file, I understand that
the folder that contains the .master files, will also contain a file
name 'CF'. Is that correct?
    - Since you need to select certain values of W from the 0th file,
you will need a GUI to display and select the values of W from it. Is
this what you want? Do you want the application to limit the displayed
rows to those between 380 and 780, or do you want it to display all
rows?

     The control flow for the application is now as follows:
       - The application starts
       - Prompts the users to select the 0th and the 15th file
       - Displays the contents of the 0th file and asks the user to
select the rows he requires
       - Performs the reqd calculations and displays the data.
     Please tell me if the above flow is ok for you, or if you want any changes.

Also, it would be very helpful if you could provide a set of data
files that I can use to test the application. You can compress (rar or
zip) the folder containing a set of data files (the masters and the CF
file), and upload it to the RapidShare website
(http://www.rapidshare.de/). Then just post the download link they
provide here, and I will be able to download it.


One final item. The price of $80 for this question is significantly
less than the expected amount for questions that require the amount of
time and effort that this does. I would strongly urge you to look at
the Google Answers pricing guideline, and revice the price
appropriately.
       - Google Answers Pricing Guidelines
         (http://answers.google.com/answers/pricing.html)

Looking forward to working with you.
Regards,
Theta-ga
:)

Clarification of Question by kristalys-ga on 23 Aug 2005 07:49 PDT
hello theta - thanks for helping me out - i greatly appreciate it. 
sorry about the confusion i'm really bad at trying to state this
problem in computer program terms...
here's some clarification... or some attempt at it - please don't
hesitate to let me know if you need any more clarification.

- In the question you say that we need to process the 0th and the
15th file. However, you then go on to say that these files may not be
named 0000.master and 0015.master as expected. How then can the
application identify the required files, if not by name?

>>> the machine collects data for 15 seconds, however sometimes the
machine will collect about 30 readings, sometimes 60, it's uncertain,
and once in a while it might skip a reading (making the data non
sequential), so i guess may be it might have to do a count to collect
the 0th and 15th file?


- Alternatively, would it be acceptable if the application asked
the user to manually select the 0th and the 15th file?
 
>>> hmm... i rather it not, this might pose a problem, since it may be
prone to human error - this is one of the reasons i'm trying to get a
program to do this, when done manually/by hand, after looking at the
screen/data a lot, you lose count :) (not good) especially after
working with a bunch of files all day.

- Also, from your description of the CF file, I understand that
the folder that contains the .master files, will also contain a file
name 'CF'. Is that correct?

>>>currently, since i'm doing it by hand, it's just a piece of paper
with the significant/required W's and the CF's that correspond with
it.


- Since you need to select certain values of W from the 0th file,
you will need a GUI to display and select the values of W from it. Is
this what you want? Do you want the application to limit the displayed
rows to those between 380 and 780, or do you want it to display all
rows?

>>> for the 0th and 15th file, yes, the program should select out the
specific numbers between 380 and 780 that are defined (i have a list
that i will scan in and include for you) the other numbers aren't
necessary to be displayed.  i'm just interested in a program that will
run, and when you click "calculate" it'll display 3 calculated answers
that it has gotten for all the files in the folder.


Control flow...
       - The application starts
       


       >>program selects out the 0th and 15th files in the folder
     
       >>a list of rows required will be established (the list), from
this the calculations will be done

       - Performs the reqd calculations and displays the data.


     Please tell me if the above flow is ok for you, or if you want any changes

Clarification of Question by kristalys-ga on 23 Aug 2005 07:56 PDT
oops i wasn't quite finished typing out my full answers for the
clarification i accidentally posted it before i finished... so anyway,
to further clarify heh..

 Also, from your description of the CF file, I understand that
the folder that contains the .master files, will also contain a file
name 'CF'. Is that correct?

>>>currently, since i'm doing it by hand, it's just a piece of paper
with the significant/required W's and the CF's that correspond with
it.  let me double check for you how the machine presents that - i'll
get back to you on this one later this afternoon.

Control flow...
       - The application starts
       
       >> user clicks button "CALCULATE" and the program does the following...

       >>program selects out the 0th and 15th files in the folder -
maybe something like n, n+1? to get teh 0 and 15th file? not sure if
that would work here -
     
       >>a list of rows required will be established (the list), from
this the calculations will be done

       - Performs the reqd calculations and displays the data.


simply - i just need the program to start, run, click button and
display the three answers, don't need to worry about showing all the
data, and then end button would probably be good to get out of the
program when not in use.

Thanks so much again for your help.  I've got a meeting today at noon
i'm preparing for now, and might not get back to you until later this
afternoon/if not tomorrow, but for sure i'll send you files by
tomorrow.  thanks again!  ~k.

Clarification of Question by kristalys-ga on 23 Aug 2005 08:06 PDT
about the CF, i'll just type it into excel and load it to your website
- it'd be a heck of a lot easier this way - since it's basically a
bunch of numbers i have scrawled out on a piece of paper.  it's about
30ish numbers - the req'd W's and the CF's that correspond with it. 
Maybe when you run the application it'll automatically open this file
(like have it implemented with the program), and then just pull the
numbers from that.

Clarification of Question by kristalys-ga on 23 Aug 2005 08:08 PDT
Control flow...
       - The application starts
       
       >> user clicks button "CALCULATE" and the program does the following...

       >>program selects out the 0th and 15th files in the folder -
maybe something like n, n+1? to get teh 0 and 15th file? not sure if
that would work here -

>> the excel file is opened with the required numbers for the calculation
     


       - Performs the reqd calculations and displays the data.

sum of all 0th file, sum of all 15th file, quotient of 0th/15th

Clarification of Question by kristalys-ga on 23 Aug 2005 09:48 PDT
here's the link for the w's and their respective cf's

http://rapidshare.de/files/4291339/w_cf.xls.html

it's in an excel file, please let me know if it opens ok.  thanks.

Clarification of Question by kristalys-ga on 23 Aug 2005 11:33 PDT
i'm attaching 2 data sample data files that come out of the machine, i
cut and pasted the results into notepad - so it's a *.txt file - i
wasn't sure if all computers can see the *.master file and i can
always change the extension myself in the vb code.  it's loaded onto
the file share program you have...

http://rapidshare.de/files/4294671/00000.txt.html
http://rapidshare.de/files/4294690/00001.txt.html

hope it works out.  thanks.  ~k.
Answer  
Subject: Re: Visual Basic 6.0 Program/Code for a Data Calculating Program
Answered By: theta-ga on 26 Aug 2005 01:55 PDT
 
Hi kristalys-ga,
   You can download the VB6 project from
[http://rapidshare.de/files/4380479/DataProcessor.zip.html].
   Click on the .vbp file to open it in the VB6 editor. 
   Some points to note:
    - While it is possible to read the excel file containing the CF
data from VB, I felt that this would make a project of this size
needlessly complicated. So the application expects the CF data to be
in a tab delimited text file format.
      To convert your excel file to this format:
         1. Open the file w_cf.xls in MS Excel
         2. From the 'File' menu, choose 'Save As...'
         3. In the 'Save As Type' dropdown, select "Text (Tab Delimited)"
         4. Save the file as cf.txt

    - The application expects the CF file ('cf.txt') to be available
in the same folder that contains the master files. If the app is not
able to find cf.txt in that folder, you will get an error.

    - The application defines a number of constant values at the
beginning of the code. You can modify these constants to change the
name of the cf file the app looks for, the folder in which it looks
for all these files, etc.

----------------------

Here is the final control flow for the application:
 - The application starts
 - it automatically looks in the 'C:\pl' folder for the 1st and the
16th .master files, and the cf.txt file. If any of these files are not
found, you get an error.
 - If the cf.txt is found, the applications reads all the W and CF
values in it into the memory
 - When the user clicks the 'Calculate' button, the application
calculates the sum of products for the two master files, and the
quotient. it then rounds them out to 5 digits after the decimal point,
and displays them.
 - You can now replace the .master files in the folder with a new set,
and then press the 'Reload' button to calculate the new products and
quotient.

-------------------------

While I have performed limited testing of the code, I strongly
recommend that you test the code with the data files you have to
ensure that the calculated results it displays are correct.
The code is well documented, and you should not have any major
problems in following the flow. Information on the various VB6
statements used can be found in the MSDN help files that come with
your VB6 installation.

If you still have any queries or have problems getting the code to
run, just post a request for clarification here, and I will be glad to
help you out.

Hope this helps!
Regards,
Theta-ga
:)

Request for Answer Clarification by kristalys-ga on 03 Sep 2005 06:06 PDT
hi theta-ga - thanks so much for the help!

i installed it, and it seems to work fine.  however, now sometimes the
machine throws other files out with the same .master extension but
it's not part of the calculation (i think it may have a conflict with
the other machine i hooked up too that does the same thing?)

anyhow, i was thinking, maybe to add an extension to the file name?
like before i start the machine the machine's own program prompts can
name the file or you can skip this.  like you can call it
"thisfile.00001.master", "thisfile.00002", etc, and have those all
sent to the c:/pl folder.  i figured at first this wasn't necessary
and just clicked them all as just plain "00000.master" but now i
figure this might be a problem when runnign this program with the
machines.
to alleviate this, i figure now that once i named it
"thisfile.*.master" and added a text box in your program and have it
only call up the one's wiht "thisfile.*.master" and ignore the other
ones that say "other.00002.master" it might work out.  i was just
wondering now, is there a line of code that might be added to just
only use "thisfile.*.master" files for the calculation in the rest of
your program?  sorry about this i really didnt' think it would have
been a conflict at all, but thanks so much again ~k.

Request for Answer Clarification by kristalys-ga on 03 Sep 2005 06:10 PDT
-program starts/calls up c:/pl and cf.txt like normal
-user types in first extension of filename (i.e. "thisfile" for
"thisfile.*.master") to use these only
-program only looks at "thisfile.*.master" files
-program runs as normal..

Clarification of Answer by theta-ga on 06 Sep 2005 09:00 PDT
Hi kristalys-ga,
   Sorry for taking so long to reply. I am in the middle of a move to
a different city, hence the delay.
   I believe there is a line of code that you can change to get the
result you want. I don't have the code with me right now, but i will
test it out and post the code here for you.
   This might take me a couple of days. 
   Sorry for the delay again.
Regards,
Theta-ga
:)

Request for Answer Clarification by kristalys-ga on 12 Sep 2005 10:00 PDT
ok thanks a bunch good luck with the move :)

Clarification of Answer by theta-ga on 12 Sep 2005 21:24 PDT
Hi kristalys-ga,
   Download an updated version of the VB6 project from here:
     http://rapidshare.de/files/5039692/DataProcessor1.1.zip.html

   I have made just one change to the code. I added a new constant
value called FileMask to the constants section at the beginning of the
code. The rest of the code uses the FileMask value to search for the
master files.
   Right now, the FileMask value is set to "*.master", as defined in
your original question.
   If you want to change this value to 'thisfile.*.master', just modify the line:
     Const FileMask = "*.master"
   to:
     Const FileMask = "thisfile.*.master"
    
   Please test out the code and see whether the results are acceptable or not.
   If you need any clarifications, just ask! :)
Regards,
Theta-ga
:)

Request for Answer Clarification by kristalys-ga on 14 Sep 2005 09:42 PDT
hey theta - thanks - however this thread locks up once in a while for
no reason - so i kind of moved it to pay another $200 for an
elaboration to the program already written - my boss was so impressed
by your first program, that there is a need for a more complex version
- please see new thread - thanks so much again!

Request for Answer Clarification by kristalys-ga on 15 Sep 2005 12:56 PDT
hi theta - i've been having on/off issues with accessing google
answers/this thread so i started another one - it's a
continuation/alteration of your program and pays $200 if interesting
in taking a look at it.  thanks again for your help -k.

Clarification of Answer by theta-ga on 15 Sep 2005 21:50 PDT
Hi kristalys-ga,
  I'll take a look at it.
  Thanks for the heads up!
Theta-ga
:)
Comments  
Subject: Re: Visual Basic 6.0 Program/Code for a Data Calculating Program
From: theta-ga on 24 Aug 2005 02:40 PDT
 
Hi kristalys-ga,
  Thanks for the clarifications!
  I'll get to work on this right now. Hopefully should have something
for you by tonight.
Regards,
Theta-ga
:)
Subject: Re: Visual Basic 6.0 Program/Code for a Data Calculating Program
From: kristalys-ga on 25 Aug 2005 08:36 PDT
 
hello - how's it going? - i will be out of the office until sunday.  i
might/might not be able to pick up an internet connection, so my
responses may be limited or none until then.  thanks again ~k.
Subject: Re: Visual Basic 6.0 Program/Code for a Data Calculating Program
From: kristalys-ga on 30 Aug 2005 17:58 PDT
 
hi - thanks - i got a chance to briefly look at it today - was out of
town (new orleans to be exact :( from last week, but left early
sunday) anyway, so far it looks good - i really appreciate it, i'm
going to try it out and post any more questions/comments i might have.
 thanks - k.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy