Mach1pro
asked on
Create Random access file in VB that is same format as NSBasic
I am trying to convert a program that was using an Access database that synchronized between a PocketPC and Microsoft Access. What I am wanting to do is create a random access file in VB that can be copied down to the handheld and then read in by record number. The problem is that when I create a random file in VB, the format doesn't match that of a random file created by NSBasic (which is supposed to be VB script). Is there anyone familiar enough with both of these programs that can tell me how to create a random file that can be read by both programs?
Here is my basic syntax for opening the file in VB:
Open myFile For Random As #1 Len = 500
Here is my syntax for opening the file in NSBasic:
file.Open myFile, 4, 2, 3, 500
Here is my basic syntax for opening the file in VB:
Open myFile For Random As #1 Len = 500
Here is my syntax for opening the file in NSBasic:
file.Open myFile, 4, 2, 3, 500
the 2 in your file.Open statement indicates it is being opened for write operations. What do your VB output statements look like and what do your NSBasic read statements look like?
The SEEK command is used for getting/setting a position within a File. It takes as a parameters an open file handle.
Say you have a file, and you know that at position 100, there is some data that you want. You can use the SEEK command to immediately set a position in the file, so that the next read from the file, starts at position 100.
You can also use the seek command to find out the current position within the file
For all files NOT opened in Random Access mode, the seek always deals with a position within the file, counting each byte.
For files opened in Random mode, the seek deals with a specific record number, for which records can be many bytes each.
Seek #filehandle,position to set the location
Seek(filehandle) to get the location
Dim fh as long
Dim n as long
fh = FreeFile
Open "file" for binary access read as #fh 'open file ready only
Seek #fh, 100
get #fh,, n 'read a long value from the file
Say you have a file, and you know that at position 100, there is some data that you want. You can use the SEEK command to immediately set a position in the file, so that the next read from the file, starts at position 100.
You can also use the seek command to find out the current position within the file
For all files NOT opened in Random Access mode, the seek always deals with a position within the file, counting each byte.
For files opened in Random mode, the seek deals with a specific record number, for which records can be many bytes each.
Seek #filehandle,position to set the location
Seek(filehandle) to get the location
Dim fh as long
Dim n as long
fh = FreeFile
Open "file" for binary access read as #fh 'open file ready only
Seek #fh, 100
get #fh,, n 'read a long value from the file
ASKER
Here is the code from NSBasic used to create a one record random access file.
Dim myArray
Redim myArray(3)
file.Open strDir, 4, 2, 3, 500
myArray(1) = 2
myArray(2) = "75"
file.Put myArray
file.close
Here is a link to the file that it created: http://www.gadatapro.com/tlcomp.txt
NOW... How do I write the VB6 syntax to read these values back in on the desktop???
Dim myArray
Redim myArray(3)
file.Open strDir, 4, 2, 3, 500
myArray(1) = 2
myArray(2) = "75"
file.Put myArray
file.close
Here is a link to the file that it created: http://www.gadatapro.com/tlcomp.txt
NOW... How do I write the VB6 syntax to read these values back in on the desktop???
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.