Home > Software engineering >  VBS how to read a text file containing fixed format
VBS how to read a text file containing fixed format

Time:09-23

Type Dog
W As Long
H As Long
End Type
Sub storage structure text file ()
Dim DogPoint As Dog
Open "d: \ test. TXT" For Binary Access Write As # 1
For I=1 To 10
With DogPoint
W.=I
H=I * 2
End With
Put # 1, and DogPoint
Next
The Close
End Sub

So save the structure of the body, with VBS read how to write? (note that is not a VB, nor VBA, is read text writing VBS.)

CodePudding user response:

VBS directly through Scripting. FSO to read,

CodePudding user response:

Structure after storage for text, numerical becomes like a memory, is about 4 bytes represents a numeric value, then what is the carry of on any account, and the processing of the decimal part, cannot simply read can use.

CodePudding user response:

You post the code is a VB6, or the VBS?

If it's VBS, since can use Binary write, can't read in Binary?

CodePudding user response:

The code above is vb and vba code,,, there is no structure of the VBS
So how to save, how to take not achieve them.

CodePudding user response:

reference 4 floor qq_29209253 response:
the code above is vb and vba code,,, there is no structure of the VBS
So how to save, how to take not achieve them.

The result of the code, write to the file is not a "text",
So you can't "numerical read the original text way out",

Has examined the data, the VBS does not support the "binary approach" to read and write files, also does not support the "custom data type (structure)",
To read binary data, can use the Adodb library. The Stream object to operate;
But to "restore data", only based on the characteristics of "structure members", according to the byte value multiplied by the corresponding multiple additive way to deal with again,

But because of the limitation of VBS can only handle writing binary data in "integer" way,
Otherwise, if you want to deal with Single or Double type, and she had to call API to implement around a curved,

CodePudding user response:

Of course, the members of the "structure", there is only a split into a single variable, or by "array",

CodePudding user response:

Computer memory or file content or transport it is just a one-dimensional binary byte array and its corresponding binary address;
The human brain to a computer memory or file contents or transfer the content of the one-dimensional binary byte array and its corresponding binary address some parts as an integer, number of signed/unsigned number, floating point Numbers, complex Numbers, letters, digits, Chinese/Korean/French... Character/string, assembly instructions, functions, function parameters, heap, stack, arrays, Pointers, array pointer and pointer array, the array of arrays, pointer to pointer, two-dimensional arrays, character lattice, the coordinates of character strokes, black and white binary images and grayscale images, color images, audio, video, fingerprint information, id information...

Recommended WinHex software to check the hard disk or file or original bytes of memory content,
  • Related