Solved

Calculate values from a text file

Posted on 2000-04-17
8
187 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
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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

828 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