Assume I have the following code:
Dim VarByte As Byte
Dim VarInt As Integer
Dim VarStr As String
Open gFileName For Binary As gFN
Get #gFN, , VarByte ' 1 byte
Get #gFN, , VarInt ' 2 bytes
Get #gFN, , VarStr ' ?? bytes
Since the first two Var's each have a fixed length, the first two GETs
together will successfully retrieve 3 bytes from the file. (I have
successfully done this, and it worked as expected.) But obviously, there
will be a problem with the fourth GET. I know that the next ten bytes in the
file are text, and I want to put them into VarStr. Is there a way to define
VarStr as always having a length of 10? Or is there a way to specify in the
GET to get 10 bytes? Or do I have to GET 10 bytes, one at a time, and
concatenate them? Thank for any help. 5 7981
Inline :-
On Sat, 13 Sep 2003 22:08:58 GMT, "William Bub"
<fa********@hotmail.com> wrote: Assume I have the following code:
Dim VarByte As Byte Dim VarInt As Integer Dim VarStr As String Open gFileName For Binary As gFN Get #gFN, , VarByte ' 1 byte Get #gFN, , VarInt ' 2 bytes
VarStr = Space$( 10 ) ' Set its lengthGet #gFN, , VarStr ' ?? bytes
Since the first two Var's each have a fixed length, the first two GETs together will successfully retrieve 3 bytes from the file. (I have successfully done this, and it worked as expected.) But obviously, there will be a problem with the fourth GET. I know that the next ten bytes in the file are text, and I want to put them into VarStr. Is there a way to define VarStr as always having a length of 10? Or is there a way to specify in the GET to get 10 bytes? Or do I have to GET 10 bytes, one at a time, and concatenate them? Thank for any help.
You could also used a Fixed Length String
Or even better a UDT containing all the variables, including a fixed
length string.
<snip> Is there a way to define VarStr as always having a length of 10?
<snip> You could also used a Fixed Length String
Or even better a UDT containing all the variables, including a fixed length string.
Thanks. That was my question. I guess the answer is "yes." New question:
How? How do you define a fixed length string?
> > > Is there a way to define VarStr as always having a length of 10?
<snip> You could also used a Fixed Length String
Or even better a UDT containing all the variables, including a fixed length string.
Thanks. That was my question. I guess the answer is "yes." New question: How? How do you define a fixed length string?
Pretty much the way it's described in the VB Help files. Look up Dim
Statement and check the section describing "type".
Rick - MVP
"Rick Rothstein" <ri************@NOSPAMcomcast.net> wrote in message
news:Cz********************@comcast.com... > Is there a way to define >VarStr as always having a length of 10? <snip> You could also used a Fixed Length String
Or even better a UDT containing all the variables, including a fixed length string.
Thanks. That was my question. I guess the answer is "yes." New
question: How? How do you define a fixed length string?
Pretty much the way it's described in the VB Help files. Look up Dim Statement and check the section describing "type".
Rick - MVP
I'm using the "Working Model" Version of VB 6.0. There are no help files,
and the textbook doesn't mention fixed length strings. Is there a good web
site with this kind of info?
> > > How? How do you define a fixed length string? Pretty much the way it's described in the VB Help files. Look up Dim Statement and check the section describing "type".
Rick - MVP
I'm using the "Working Model" Version of VB 6.0. There are no help files, and the textbook doesn't mention fixed length strings. Is there a good web site with this kind of info?
Okay, the syntax is
Dim StringVariableName As String * FixedCharacterSize
where you put the string variable name in the obvious spot and replace the
FixedCharacterSize indicator with a hard-coded number, such as 10, to make a
fixed string of 10 characters. (You must use an actual number; a variable
won't work.)
Although it is somewhat cumbersome to use, you can view the entire MSDN Help
Files online at this link... http://msdn.microsoft.com/library/default.asp
Specifically, open the "tree" to this...
Visual Tools and Languages
Visual Studio 6.0
Visual Basic 6.0
Product Documentation
Reference
Language Reference
Rick - MVP This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Olivier Maurice |
last post by:
Hi all,
I suppose some of you know the program Redmon (type redmon in google, first
result). This neat little tool allows to hook up any functionality to a
printer by putting the file printed...
|
by: Lionel B |
last post by:
Greetings,
I need to read (unformatted text) from stdin up to EOF into a char
buffer; of course I cannot allocate my buffer until I know how much
text is available, and I do not know how much...
|
by: Magnus |
last post by:
allrite folks, got some questions here...
1) LAY-OUT OF REPORTS
How is it possible to fundamentaly change the lay-out/form of a report in
access? I dont really know it that "difficult", but...
|
by: Rajorshi Biswas |
last post by:
Hi folks,
Suppose I have a large (1 GB) text file which I want to read in
reverse. The number of characters I want to read at a time is
insignificant. I'm confused as to how best to do it. Upon...
|
by: nnimod |
last post by:
Hi. I'm having trouble reading some unicode files. Basically, I have to
parse certain files. Some of those files are being input in Japanese,
Chinese etc. The easiest way, I figured, to distinguish...
|
by: jccorreu |
last post by:
I've got to read info from multiple files that will be given to me. I
know the format and what the data is. The thing is each time we run
the program we may be using a differnt number of files,...
|
by: arne.muller |
last post by:
Hello,
I've come across some problems reading strucutres from binary files.
Basically I've some strutures
typedef struct {
int i;
double x;
int n;
double *mz;
|
by: Tyler |
last post by:
Hello All:
After trying to find an open source alternative to Matlab (or IDL), I
am currently getting acquainted with Python and, in particular SciPy,
NumPy, and Matplotlib. While I await the...
|
by: blazedaces |
last post by:
Ok, so you know my problem, java is running out of memory reading with SAX, the event-based xml parser intended more-so than DOM for extremely large files. I'll try to explain what I've been doing...
|
by: Miner Jeff |
last post by:
Hello, I have a basic question about reading files.
I have several data files where the filenames are identical except for
a short (3 character) prefix. I inherited this code and the person who...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |