G
Guest
H
I am trying to use the FileOpen method to read a Random Access file. I first created a structure that looked like this (not completed
Public Structure ModelInf
Implements ICompare
Public intModel As Intege
Public dblPrice As Doubl
Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer Implements System.Collections.IComparer.Compar
End Functio
Public Overrides Function ToString() As Strin
Return "Model: " & intModel & ", Price: " & Format(CStr(dblPrice), "$#,##0"
End Functio
End Structur
and am trying to use it to access data in a random access file which has two columns and is delimited by a comm
using the below cod
Dim intCount As Integer = 1 ' Counter Variabl
Dim objModel As ModelInf
' Get File and Path info from Configuration Fil
strPath = System.Configuration.ConfigurationSettings.AppSettings("PATH"
strFile = System.Configuration.ConfigurationSettings.AppSettings("FILE"
'Add any initialization after the InitializeComponent() cal
FileOpen(1, strPath & strFile, OpenMode.Random, OpenAccess.ReadWrite,
OpenShare.Shared
' Load Listbo
Do While Not EOF(1
FileGet(1, objModel, intCount
intCount +=
Loo
and I am getting an error message. I know a struct is a value type and the sub wants a reference type. I am confused because the example in the book isn't seemingly all that different syntactically from what I wish to achieve. Can anyone tell me what I am doing wrong
Thank you.
I am trying to use the FileOpen method to read a Random Access file. I first created a structure that looked like this (not completed
Public Structure ModelInf
Implements ICompare
Public intModel As Intege
Public dblPrice As Doubl
Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer Implements System.Collections.IComparer.Compar
End Functio
Public Overrides Function ToString() As Strin
Return "Model: " & intModel & ", Price: " & Format(CStr(dblPrice), "$#,##0"
End Functio
End Structur
and am trying to use it to access data in a random access file which has two columns and is delimited by a comm
using the below cod
Dim intCount As Integer = 1 ' Counter Variabl
Dim objModel As ModelInf
' Get File and Path info from Configuration Fil
strPath = System.Configuration.ConfigurationSettings.AppSettings("PATH"
strFile = System.Configuration.ConfigurationSettings.AppSettings("FILE"
'Add any initialization after the InitializeComponent() cal
FileOpen(1, strPath & strFile, OpenMode.Random, OpenAccess.ReadWrite,
OpenShare.Shared
' Load Listbo
Do While Not EOF(1
FileGet(1, objModel, intCount
intCount +=
Loo
and I am getting an error message. I know a struct is a value type and the sub wants a reference type. I am confused because the example in the book isn't seemingly all that different syntactically from what I wish to achieve. Can anyone tell me what I am doing wrong
Thank you.