|
-
Aug 23rd, 2000, 03:03 PM
#1
Thread Starter
Hyperactive Member
My problem is with the get and put statement. How do you add to the end of file i.e after the last record and how do you get the last record in the file?
The line
LastRecord = LastRecord + 1
Put FileNum, LastRecord, Q2
is what Microsoft says to do but it does not work. I need a way to get the last record position then add 1 to it before I do the Put. I tried all types of loops and I just can't seem to get it right. If anyone knows how to do this please help
Thanks Troy
Here is my Bas:
Option Explicit
Type Question
Ques As String * 150
Answer1 As String * 50
Answer2 As String * 50
Answer3 As String * 50
Answer4 As String * 50
Answer5 As String * 50 'Correct answer
ID As Integer
End Type
' A record variable.
Public Q2 As Question
' Tracks the current record.
Public Position As Long
' The number of the last record in the file.
Public LastRecord As Long
Below is my code:
Public Function RndPut()
Dim FileNum As Integer, RecLength As Long, Q2 As Question
Dim FileName As String
' Calculate the length of each record.
RecLength = LenB(Q2)
' Get the next available file number.
FileNum = FreeFile
FileName = App.Path & "\Question.dat"
Open FileName For Random As FileNum Len = RecLength
'Position = List1.Text
Q2.Ques = txtQuestion.Text
Q2.Answer1 = Text1.Text
Q2.Answer2 = Text2.Text
Q2.Answer3 = Text3.Text
Q2.Answer4 = Text4.Text
Q2.Answer5 = Text5.Text
'Q2.ID = txtID
LastRecord = LastRecord + 1
Put FileNum, LastRecord, Q2
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|