f



Opening and writinging text into text files.

ok heres the problem, 
1. Design a program to:
�	Open a text file,
�	Display the contents to the user,
�	Sort the list with regards to A+ to E-,
�	Update the display,
�	Save the sorted list to a text file.
Below is a sample of the text file:
AB0123
IPT
B-
AB0154
IPT
A+
AB0187
IPT
D+
AB0201
IPT
B+
AB1031
IPT
C+

now i have no idea on how we are to do this, it is a revision question
for one of my ipt tests, and it needs to be done in VB 6,

please help!!
0
10/14/2004 12:33:03 PM
comp.programming 11491 articles. 2 followers. Post Follow

4 Replies
682 Views

Similar Articles

[PageSpeed] 37

Callum Ginty writes:

> now i have no idea on how we are to do this, it is a revision
> question for one of my ipt tests, and it needs to be done in
> VB 6,

Why don't you tell us what you CAN do.  We'll help you over
the tough spots, but most folks here won't do your work for
you.

You might want to consider this:

Read your text file line-by-line, but in groups of three lines.
Use a ListView control.  Put text from line 1 in column 1, 
line 2 in column 2, line 3 in column 3.  Sort by column 3.
Save the ListView contents in row order.

0
Chris7 (2513)
10/14/2004 2:46:10 PM

Well, read the file's content into an array of strings. You might have to 
use ReDim occasionally to increase the array.

Then sort this array using a bubble sort algorithm
(this is very easy to program, though it's not very efficient. You might 
prefer QuickSort, but this is a little bit more trickier)

I recommend you to give it a try and write down some program until you 
reach a point where you can't continue. Then post again to this newsgroup.

Besides, what kind of test is this? If you have absolutely no idea of what 
to do, then you might be working in a field which doesn't suit to you.

Georg Scholz




On 14 Oct 2004 05:33:03 -0700, Callum Ginty <callumginty@gmail.com> wrote:

> ok heres the problem,
> 1. Design a program to:
> •	Open a text file,
> •	Display the contents to the user,
> •	Sort the list with regards to A+ to E-,
> •	Update the display,
> •	Save the sorted list to a text file.
> Below is a sample of the text file:
> AB0123
> IPT
> B-
> AB0154
> IPT
> A+
> AB0187
> IPT
> D+
> AB0201
> IPT
> B+
> AB1031
> IPT
> C+
>
> now i have no idea on how we are to do this, it is a revision question
> for one of my ipt tests, and it needs to be done in VB 6,
>
> please help!!



-- 
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
0
10/14/2004 4:13:00 PM
From: callumginty@gmail.com  (Callum Ginty)

>ok heres the problem, 
>1. Design a program to:
>•	Open a text file,
>•	Display the contents to the user,
>•	Sort the list with regards to A+ to E-,
>•	Update the display,
>•	Save the sorted list to a text file.
>Below is a sample of the text file:
>AB0123
>IPT
>B-
>AB0154
>IPT
>A+
>AB0187
>IPT
>D+
>AB0201
>IPT
>B+
>AB1031
>IPT
>C+
>
>now i have no idea on how we are to do this, it is a revision question
>for one of my ipt tests, and it needs to be done in VB 6,
>
>please help!!

IPT test.   Is that a pregnancy test or something???

Sounds to me like you probably need to pay more attention in class or at least
spend more time studying.

Dan  :-)
0
dantex1 (525)
10/15/2004 2:15:39 AM
On 14 Oct 2004 05:33:03 -0700, callumginty@gmail.com (Callum Ginty)
wrote:

>ok heres the problem, 
>1. Design a program to:
>�	Open a text file,
>�	Display the contents to the user,
>�	Sort the list with regards to A+ to E-,
>�	Update the display,
>�	Save the sorted list to a text file.

[snip data file]

>now i have no idea on how we are to do this, it is a revision question
>for one of my ipt tests, and it needs to be done in VB 6,
>
>please help!!

No I won't do your homework, however here are some hints to get you
started.

First read the question: you have to design a program to do five
things in order.  To me that would suggest that you need to have four
or five functions and then call them in order.  The pseudocode would
be something like:

begin
   read data from file
   if (data not read) then abort with message endif

   display data in original order

   sort data by grade

   redisplay data in sorted order

   save sorted data to disk
   if (data not saved) then abort with message endif
end

The data from the file will need to go into some kind of object.  Look
through VB for an object that can hold the data and that comes with
built-in functions to load from disk, save to disk, display on screen
and sort.  Or at least one that does as many as possible of them.
Each built-in function is less work for you to do later.

Try getting each of these functions to work separately, then put them
together.  First just open the file and display its contents in the
original order.  The start building on that by adding the sort, the
second display and the save to disk in turn.  Test your program after
you add each new function to make sure that it still works.

If you get into problems, post what you have done here, or on a VB
specific newsgroup, with an explanation of the problem you are having.
The more work you show, the more help you are likely to get.


rossum


--

The ultimate truth is that there is no Ultimate Truth
0
rossum48 (719)
10/16/2004 9:54:30 PM
Reply: