• YOU can help the next generation of students in the community!
    Share your trial papers and notes on our Notes & Resources page

Need URGENT Help!!!!! (1 Viewer)

Cutieangel

New Member
Joined
Mar 18, 2004
Messages
13
Location
Oatley
For my Major Project, I am creating a program where it has a database function - enter records, search records, sort records, delete records etc, however, I am not using a database. Thus, I really need help.

1. When I click on my program for 'save new record', it overrides the existing premade records I made before,

Dim iCurrentRecord As Integer
If Dir(OUTPUT_FILE) <> "" Then
Kill OUTPUT_FILE
End If
Open OUTPUT_FILE For Random As #1 Len = 88
For iCurrentRecord = 0 To Counter - 1
Put #1, iCurrentRecord + 1, ArrayUacRecords(iCurrentRecord)
Next iCurrentRecord
Close #1

MsgBox CStr(Counter) & " UAC records have been saved to " & OUTPUT_FILE, vbInformation

This code overides the existing records that I have made... is there a way that it will just add to it.

2. I am trying to create a search, however, it doesn't work. I can only get it to work if I search and find ONE record only, but for my program, I need to keep searching, and keep finding... so the result should display all the records that I have the keyword of.

Private Sub cmdsearch_Click()
Dim Found As Boolean
Dim Position As Integer
Dim records(24) As UacRecord
Dim i As Integer
Open "C:\records.txt" For Input As #1
i = 0
Do While Not EOF(1) And i < 24
Input #1, records(i).University, records(i).Course, records(i).UAI
i = i + 1
Loop
i = 0
Found = False
Do While i < 25 And Found = False
If Trim(records(i).University) = Trim(txtUNIsearch.Text) Then
Found = True
Position = i
txtdisplay.Text = records(i).University & records(i).Course & records(i).UAI
End If
i = i + 1
Loop
If Found = False Then
MsgBox ("University not found!"), vbOKOnly
End If

Close #1

End Sub

When I run this, an error appears in this line : Input #1, records(i).University, records(i).Course, records(i).UAI
and says ' ... past end of file'

3. I have no idea how to sort. I want to display all the records, then have a sort button, and it would sort it ascending according to university name. However, the problem is that the records are displayed on the form, and not in textboxes, thus I don't know how to sort.

4. When I enter a record, it saves it. But when I open the file that I saved it to, it just has symbols and some characters. Why is this, how can I fix it? I save it in a .txt file in a notepad


Hope you can help me.


P.S I need help prior 9th June 2004 .... thanks
 

J0n

N/A
Joined
Aug 28, 2003
Messages
410
Gender
Male
HSC
2004
Originally posted by Cutieangel
1. When I click on my program for 'save new record', it overrides the existing premade records I made before,

Dim iCurrentRecord As Integer
If Dir(OUTPUT_FILE) <> "" Then
Kill OUTPUT_FILE
End If
This might be your problem, as that code checks if the file exists, if so, it deletes it :confused:

For the second one:
Do While Not EOF(1) And i < 24
try and put brackts around the different conditions e.g
Do While (Not EOF(1)) And (i < 24)
cause it might be interpreted as:
Do While Not (EOF(1) And i < 24)

Also, your search only loops while Found = False
Originally posted by Cutieangel
Do While i < 25 And Found = False
And as soon as you find an item you set Found to True
Originally posted by Cutieangel
If Trim(records(i).University) = Trim(txtUNIsearch.Text) Then
Found = True
Position = i
txtdisplay.Text = records(i).University & records(i).Course & records(i).UAI
End If
Also, since you say:
txtdisplay.Text = records(i).University & records(i).Course & records(i).UAI
every time a new record is found, it replaces the contents of txtdisplay .'. all you will see is the contents of the last record found (if you didn't have that Found = True statment).

For the thrid one, did you print them straight on the form? Why didn't you just use a ListBox?

For the fourth one, i'm not sure, but it could be cause you open your file For Random, why don't you open For Append?

Lastly, since you are doing all this database stuff, why don't you use a 'real' database like Access or something??
 
Joined
May 27, 2004
Messages
107
Gender
Male
HSC
2004
what lanuage u using...

database is the best way of doing it aswell rather then text documents and its easier to sort and read aswell
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top