'---------------------------------------------
'How To: Read and Write to a Random File Type?
'Posted: 08-June-00
'Author: Marcel Broesky
'
'Description: Sample code for reading and writing
'to and from Random File Types.
'---------------------------------------------
Private Type employee
empID As Integer
lname As String * 30
fname As String * 20
title As String * 20
End Type
----------------------------------------------------------------------
Private Sub Command1_Click()
Dim emp1 As employee
Open "d:\tdv\dat\dat.dat" For Random As #1 Len = Len(emp1)
For i = 1 To 5
Get #1, i, emp1
Text1.Text = Text1.Text & "Name: " & Trim$(emp1.fname) & " " &
Trim$(emp1.lname) & vbCrLf & "Title: " & Trim$(emp1.title) & _
vbCrLf & "ID: " & Trim$(emp1.empID) & vbCrLf
Next
Close #1
End Sub
----------------------------------------------------------------------
Private Sub Command2_Click()
Dim emp1 As employee
Open "d:\tdv\dat\dat.dat" For Random As #1 Len = Len(emp1)
For i = 1 To 5
With emp1
.lname = InputBox$("Enter Last Name")
.fname = InputBox$("Enter First Name")
.title = InputBox$("Enter Title")
.empID = i
End With
Put #1, , emp1
Next i
Close #1
End Sub
'----------------------------
'Burt Abreu
'Visual Basic Explorer
'http://www.VBExplorer.com
'June 07, 2000
'----------------------------
Downloads
In IE right-click and select 'Save Target As...' or in Netscape
right-click and select 'Save Link As...'
View Plain Text
Not Available
Not Available