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.Collecti ons.IComparer.C ompar
End Functio
Public Overrides Function ToString() As Strin
Return "Model: " & intModel & ", Price: " & Format(CStr(dbl Price), "$#,##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.Configur ation.Configura tionSettings.Ap pSettings("PATH "
strFile = System.Configur ation.Configura tionSettings.Ap pSettings("FILE "
'Add any initialization after the InitializeCompo nent() cal
FileOpen(1, strPath & strFile, OpenMode.Random , OpenAccess.Read Write,
OpenShare.Share d
' 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.Collecti ons.IComparer.C ompar
End Functio
Public Overrides Function ToString() As Strin
Return "Model: " & intModel & ", Price: " & Format(CStr(dbl Price), "$#,##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.Configur ation.Configura tionSettings.Ap pSettings("PATH "
strFile = System.Configur ation.Configura tionSettings.Ap pSettings("FILE "
'Add any initialization after the InitializeCompo nent() cal
FileOpen(1, strPath & strFile, OpenMode.Random , OpenAccess.Read Write,
OpenShare.Share d
' 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.
Comment