Hi Friends,
The general code in my project is as below:
In Module:
----------
Structure TopDataType
'UPGRADE_WARNING: Fixed-length string size must fit in the buffer.
<VBFixedString(40),System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray,SizeConst:=40)> Public TopName() As Char 'TopData.HDName
Dim Catagory As Short 'TopData.Catagory
Dim Status As Short 'TopData.Status
Dim Deleted As Short 'TopData.Deleted
'UPGRADE_WARNING: Fixed-length string size must fit in the buffer.
<VBFixedString(100),System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray,SizeConst:=100)> Public Extra() As Char 'TopData.Extra
End Structure
---------------------
In Form1:
----------
Private Sub TopDataSave()
Dim TopData As TopDataType 'Above Structure
shtFF = FreeFile
strMyDataFile = My.Application.Info.DirectoryPath & "\MY DATA FILE\MyDataFile.DAT"
FileOpen(FF, strMyDataFile, OpenMode.Random, , , Len(TopData))
TopRecords = LOF(FF) \ Len(TopData)-1
If TopRecords > 0 Then
'
For Rec = 1 To TopRecords
'UPGRADE_WARNING: Get was upgraded to FileGet and has a new behavior.
If Not EOF(FF) Then FileGet(FF, TopData, Rec)
'
If TopData.Deleted = True Then
TopData.TopName = ""
TopData.Catagory = 0
TopData.Status = 0
'
'UPGRADE_WARNING: Put was upgraded to FilePut and has a new behavior.
FilePut(FF, TopData, Rec)
End If
'
Next Rec
End If
FileClose(FF))
End Sub
-------------------------------------------
I am getting these Errors in FileOpen, FileGet,etc. How to identify & correct these errors?
->
MyCode : If Not EOF(FF) Then FileGet(FF, TopData, Rec)
Error : "Array dimensions do not match those specified by the 'VBFixedArray' attribute."
->
MyCode : FileOpen(1, PipeJobFile, OpenMode.Binary, , , Len(PipeJob))
Error : "File already open.
How to check whether a file is open before attempting to open it?
->
MyCode : If Not EOF(FF) Then FileGet(FF, TopData, Rec)
Error : "Argument 'RecordNumber' is not a valid value.
->
MyCode : ParentForm.Name = "frmExample"
Error : "Object reference not set to an instance of an object.
Regards,
Simran.