OptionStrictがオンのときに表示されるバイナリファイルから構造データを読み取る機能に問題があります。
Public Function arh_setup(ByVal rw As Boolean) As Integer Dim retval As Integer = 0 Dim fnum As Integer = FreeFile() Dim temp As ValueType = CType(New aSetup, ValueType)
Try
FileOpen(fnum, setup_file, OpenMode.Binary, OpenAccess.ReadWrite, OpenShare.Shared, Len(asT))
If rw Then
FilePut(fnum, asT, 1)
Else
FileGet(fnum, temp, 1)
End If
FileClose(fnum)
Catch ex As Exception
retval = -1
End Try
' Now is question here
' How to get data from temp to asT??
EDIT:
Solution is asT = CType(temp, aSetup)
temp= Nothing
Return retval
End Function
asTは、(適切に)読み取られたデータを含むtempからデータを取得する必要があるタイプaSetup(構造)のグローバルに宣言された変数です。
問題は、ローカル一時変数からグローバルasT変数に、できればループせずに(バイトごとに)、または可能でない場合はループして、データをコピーする方法です。