Type data
As a long
B as long
End type
Open the App. The Path & amp; "\ data. Dat" For the Random As # 1 Len=Len (data)
Commonly used method is to read cycle, the speed is too slow, how can block read
Such as the read pointer is 2-20 to save data to an array
CodePudding user response:
Do you want to read "blocks", should file in Binary mode operation to just go!
If you want to read and write "array structure" of the middle section elements ", "
1 d array is better to do, can reduce the corresponding "data area" is bound to a Byte array, and set up corresponding Byte size,
Then you can directly through an array of bytes, "read a piece of data"
Multidimensional would be in trouble, because VB6 multi-dimensional array, is different from "usually believed" sequential,
CodePudding user response:
Examples of relief the files directly into memory, and then you slowly processing,
Private Sub Command2_Click () Dim aryInput () As Byte The Debug Print Now (), "start" ReDim aryInput (FileLen (" B: \ 1. TXT ")), 'according to the length of the file set the data read from the memory size B: \ 1. TXT "Open" For Binary As # 1 The Get # 1, and aryInput Close # 1 The Debug Print Now (), "at the end of input file is read," End Sub CodePudding user response:
Like upstairs said, using Binary mode to open the file, and can locate the Get statements to you want to read the file location, and then read the size of a specified array data,
CodePudding user response:
refer to the second floor chewinggum response: relief example of the file read into memory directly, and then you slowly processing, Private Sub Command2_Click () Dim aryInput () As Byte The Debug Print Now (), "start" ReDim aryInput (FileLen (" B: \ 1. TXT ")), 'according to the length of the file set the data read from the memory size B: \ 1. TXT "Open" For Binary As # 1 The Get # 1, and aryInput Close # 1 The Debug Print Now (), "at the end of input file is read," End Sub File a lot can't read into the array CodePudding user response:
reference 4 floor FrankWang response: Quote: refer to the second floor chewinggum response: Examples of relief the files directly into memory, and then you slowly processing, Private Sub Command2_Click () Dim aryInput () As Byte The Debug Print Now (), "start" ReDim aryInput (FileLen (" B: \ 1. TXT ")), 'according to the length of the file set the data read from the memory size B: \ 1. TXT "Open" For Binary As # 1 The Get # 1, and aryInput Close # 1 The Debug Print Now (), "at the end of input file is read," End Sub File a lot can't read in the array Read separately Get # 1, XXXX, aryInput specify the read/write position CodePudding user response:
reference 5 floor bakw reply: Quote: refer to 4th floor FrankWang response: Quote: refer to the second floor chewinggum response: Examples of relief the files directly into memory, and then you slowly processing, Private Sub Command2_Click () Dim aryInput () As Byte The Debug Print Now (), "start" ReDim aryInput (FileLen (" B: \ 1. TXT ")), 'according to the length of the file set the data read from the memory size B: \ 1. TXT "Open" For Binary As # 1 The Get # 1, and aryInput Close # 1 The Debug Print Now (), "at the end of input file is read," End Sub File a lot can't read in the array Read separately Get # 1, XXXX, aryInput specifies the position to read and write good Such a reading is BYTE, to turn the TYPE format is in trouble is not CodePudding user response:
refer to 6th floor FrankWang response: Quote: refer to the fifth floor bakw reply: Quote: refer to 4th floor FrankWang response: Quote: refer to the second floor chewinggum response: Examples of relief the files directly into memory, and then you slowly processing, Private Sub Command2_Click () Dim aryInput () As Byte The Debug Print Now (), "start" ReDim aryInput (FileLen (" B: \ 1. TXT ")), 'according to the length of the file set the data read from the memory size B: \ 1. TXT "Open" For Binary As # 1 The Get # 1, and aryInput Close # 1 The Debug Print Now (), "at the end of input file is read," End Sub File a lot can't read in the array Read separately Get # 1, XXXX, aryInput specifies the position to read and write good Such a reading is BYTE, to turn the TYPE format is more trouble not Don't trouble, if you want to switch to a string, using StrConv function is ok, CodePudding user response:
refer to 6th floor FrankWang response: Quote: refer to the fifth floor bakw reply: Quote: refer to 4th floor FrankWang response: Quote: refer to the second floor chewinggum response: Examples of relief the files directly into memory, and then you slowly processing, Private Sub Command2_Click () Dim aryInput () As Byte The Debug Print Now (), "start" ReDim aryInput (FileLen (" B: \ 1. TXT ")), 'according to the length of the file set the data read from the memory size B: \ 1. TXT "Open" For Binary As # 1 The Get # 1, and aryInput Close # 1 The Debug Print Now (), "at the end of input file is read," End Sub File a lot can't read in the array Read separately Get # 1, XXXX, aryInput specifies the position to read and write good Such a reading is BYTE, to turn the TYPE format is more trouble not Method is "no problem", I said you "read a byte array", it actually has at the same time in your "structure array" in the corresponding element, And to write to the file "" is the same, CodePudding user response:
reference 1st floor Chen8013 response: what do you want to read "blocks", should file in Binary mode operation to just go! nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull