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.

I have tried to find solutions for the above errors through Google and forums.

-> MyCode : FileOpen(1, TopDataFile, OpenMode.Binary, , , Len(TopData))
Error : "File already open.
How to check whether a file is open before attempting to open it (and if possible then close it before opening it)? There are solutions for checking open excel files in forums but not for notepad & .dat files in VB.Net.

-> MyCode : If Not EOF(FF) Then FileGet(FF, TopData, Rec)
Error : "Argument 'RecordNumber' is not a valid value.
http://msdn.microsoft.com/en-us/library/0dz4ktbx(v=VS.90).aspx for "Argument 'RecordNumber' is not a valid value." I just added code to check whether RecordNumber is more than 0.

-> MyCode : If ParentForm.Name = "frmExample" Then ParentForm.Name = ""
Error : "Object reference not set to an instance of an object.
Had to change the VB6 code 'ParentForm="frmExample"' to 'ParentForm.Name = "frmExample"' in VB.Net which might have created this error. How to add an instance for this object?

-> MyCode : If Not EOF(FF) Then FileGet(FF, TopData, Rec)
Error : "Array dimensions do not match those specified by the 'VBFixedArray' attribute."
http://msdn.microsoft.com/en-us/library/7y4sc6h1(VS.90).aspx
I have checked the dimensions of the array but am unable to identify the problem. How to rectify it?

Regards,
Simran.

'-- right after your declaration of TopData do the following
ReDim TopData.TopName(0 to 39)
ReDim TopData.Extra(0 to 99)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.