Solved

Calculate values from a text file

Posted on 2000-04-17
8
194 Views
Last Modified: 2010-05-02
I am working on a program that keeps track of how long each user is using Internet. I use this information to make a text file with important info. The file contains date, start- and stop time, total online time, price, and username.

The information in the text file should help me to calculate the telephone bill and make each person pay his or her percentage of the price.

Example, text file:
2000-04-16 18:31:11 18:31:31 00:00:20 0,115 0,44 User1
2000-04-16 20:59:08 20:59:40 00:00:32 0,115 0,46 User2
2000-04-16 21:18:04 21:18:33 00:00:29 0,115 0,46 User3
2000-04-17 12:16:32 12:16:42 00:00:10 0,23 0,42 User1
2000-04-17 17:33:33 17:33:45 00:00:12 0,23 0,42 User2
2000-04-17 17:34:40 17:34:55 00:00:15 0,23 0,43 User3
2000-04-17 17:49:22 17:50:17 00:00:55 0,23 0,50 User2

1. I want all the numbers in the last but one column to be summed.
2. Then I want all the user prices to be summed.
3. Then usersum/totalsum *100
4. All this should be presented a lucid way.

This was very difficult to explain but I hope you can understand what I want.
0
Comment
Question by:Ecmil
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 28

Expert Comment

by:AzraSound
ID: 2724405
are you allowed to use a database to store this information? it could make your life much easier.
0
 
LVL 15

Expert Comment

by:ameba
ID: 2724543
So, where is the problem?? You don't know how to read file, you don't know how to design interface, or what?
0
 
LVL 7

Expert Comment

by:Joe_Griffith
ID: 2724567
Your data is a little confusing.  Could you break one of the lines down and identify the values in each field?  Summing the price also seems like an odd thing to do.  Is it really the price or is it cost that you want added up?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Accepted Solution

by:
Sage020999 earned 250 total points
ID: 2724569
use the split command to break all your data into an array.  You can then sum your data with a conditional loop.
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 2724856
There is a column that I don't know what it is (first line)

date = 2000-04-16
start = 18:31:11
stop = 18:31:31
total online time = 00:00:20
price = 0,115
? = 0,44
username = User1
0
 
LVL 2

Expert Comment

by:burntout
ID: 2725151
You should make your own type
TYPE MyType
  Date as Date
  Start as Date
  Stop as Date
  Total as Long
  Price as Long
  User as String * 20
End Type

This will make it much easier to read and write to your text file.
Open the text file for random access.

or do as azrasound sugested as use a database.
0
 
LVL 2

Expert Comment

by:gerrymcd
ID: 2728699
i agree with burnout make you own type first store you inputed values into each member of this type.

each line will be an array index of a user?  so make an array of types fro each line in your text file.

you need to explain your text file better!
0
 

Author Comment

by:Ecmil
ID: 2738302
Thanks Sage, your suggestion worked. At first I wanted to avoid using a database because I thought VB could calculate the textfile easy, but apparently not. So I followed AzraSound suggestion and stored the info. in a database.

I know how to read the text file. I try explain the text file again, for those who wanted
2000-04-16 ' the date when the program started
18:31:11 ' the time when program started
18:31:31 ' the time when program ended                        
00:00:20 ' how long the program has been running            
0,115 ' the telephone fee (important to see if high or low fee) - you can leave this bit out
0,44 ' the price for 20 sec (time * fee + the call fee (0,40)) already calculated in VB
User1 ' the person how used the program for 20 sec.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question