Cutieangel
New Member
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
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