Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to send just a form feed character to print # statement

1 view
Skip to first unread message

Tony Girgenti

unread,
Nov 19, 2009, 11:31:01 AM11/19/09
to
Hello.

I'm using VB6 to create an output file.

Is there a way to simply output a line to the file with just a form feed
character(CHR(10) in it? No carriage return/line feed. Just a formfeed
character.

Here is how i open the file and write data to it.

Open OutputFile For Output As #OutNum
Print #OutNum, Space(7) + LineString + Space(6)

Any help would be gratefully appreciated.

Thanks,
Tony

Rick Rothstein

unread,
Nov 19, 2009, 11:46:41 AM11/19/09
to
If I understand what you are looking to do correctly, just concatenate
Chr$(10) into your string at the appropriate location. For example...

LineString = "One" & Chr$(10) & "Two"

--
Rick (MVP - Excel)


"Tony Girgenti" <tony(nospam)@lakesideos.com> wrote in message
news:4E675173-889F-4FDB...@microsoft.com...

Nobody

unread,
Nov 19, 2009, 11:59:31 AM11/19/09
to
"Tony Girgenti" <tony(nospam)@lakesideos.com> wrote in message
news:4E675173-889F-4FDB...@microsoft.com...

Use ";" at the end to prevent VB from appending Chr(13)+Chr(10). Examples:

Print #OutNum, Chr(10);

Print #OutNum, Space(7) + LineString + Space(6) + Chr(10);

Also try:

Debug.Print "ABC";
Debug.Print "DEF"

Output:

ABCDEF


Dee Earley

unread,
Nov 19, 2009, 12:09:49 PM11/19/09
to
On 19/11/2009 16:31, Tony Girgenti wrote:
> Hello.
>
> I'm using VB6 to create an output file.
>
> Is there a way to simply output a line to the file with just a form feed
> character(CHR(10) in it? No carriage return/line feed. Just a formfeed
> character.

Use Write #

Print # is for line based/formatted data.

--
Dee Earley (dee.e...@icode.co.uk)
i-Catcher Development Team

iCode Systems

Jeff Johnson

unread,
Nov 19, 2009, 12:30:49 PM11/19/09
to
"Tony Girgenti" <tony(nospam)@lakesideos.com> wrote in message
news:4E675173-889F-4FDB...@microsoft.com...

> Is there a way to simply output a line to the file with just a form feed


> character(CHR(10) in it? No carriage return/line feed. Just a formfeed
> character.

10 is not a form feed character; it is a line feed character. 12 is a form
feed character.


Karl E. Peterson

unread,
Nov 19, 2009, 1:50:36 PM11/19/09
to
Dee Earley wrote:
> On 19/11/2009 16:31, Tony Girgenti wrote:
>> Hello.
>>
>> I'm using VB6 to create an output file.
>>
>> Is there a way to simply output a line to the file with just a form feed
>> character(CHR(10) in it? No carriage return/line feed. Just a formfeed
>> character.
>
> Use Write #
>
> Print # is for line based/formatted data.

Wrong.
--
.NET: It's About Trust!
http://vfred.mvps.org


Jeff Johnson

unread,
Nov 19, 2009, 3:41:51 PM11/19/09
to
"Karl E. Peterson" <ka...@exmvps.org> wrote in message
news:%239$JwkUaK...@TK2MSFTNGP04.phx.gbl...

>>> I'm using VB6 to create an output file.
>>>
>>> Is there a way to simply output a line to the file with just a form feed
>>> character(CHR(10) in it? No carriage return/line feed. Just a formfeed
>>> character.
>>
>> Use Write #
>>
>> Print # is for line based/formatted data.
>
> Wrong.

Holy crap, I just skimmed the replies and didn't notice how wrong!

Write # = Same as Print # except with the addition of a bunch of stupid
quotation marks.

Print # = What you should always use even if someone tells you to use Write
#.


dpb

unread,
Nov 19, 2009, 3:59:50 PM11/19/09
to
Jeff Johnson wrote:
...

> Print # = What you should always use even if someone tells you to use Write
> #.

Not necessarily--Write # works just fine when used as intended. What is
intended is what is written w/ Write # will be read w/ Input #. If so,
the input is guaranteed to be consistent w/ the previous output
including handling such things as strings w/ embedded blanks, etc.,
correctly w/o the need for adding quotes on output manually or parsing
fields on input.

Not for everything or every purpose but useful for what it provides.

--

Karl E. Peterson

unread,
Nov 19, 2009, 4:54:47 PM11/19/09
to
dpb wrote:
> Jeff Johnson wrote:
> ...
>> Print # = What you should always use even if someone tells you to use Write
>> #.
>
> Not necessarily--Write # works just fine when used as intended. What is
> intended is what is written w/ Write # will be read w/ Input #.

Another lame construct. <g>

I dunno, if you just get used to using either Print# and Get/Put, all's well with
the world. Tossing Write# and Input# into the mix just isn't necessary.

> Not for everything or every purpose but useful for what it provides.

I suppose it's possible it's just "not for me", yeah.

dpb

unread,
Nov 19, 2009, 5:13:56 PM11/19/09
to
Karl E. Peterson wrote:
> dpb wrote:
>> Jeff Johnson wrote:
>> ...
>>> Print # = What you should always use even if someone tells you to use Write
>>> #.
>> Not necessarily--Write # works just fine when used as intended. What is
>> intended is what is written w/ Write # will be read w/ Input #.
>
> Another lame construct. <g>
>
> I dunno, if you just get used to using either Print# and Get/Put, all's well with
> the world. Tossing Write# and Input# into the mix just isn't necessary.

"Necessary?" No; never said it was... :)

But, nothing particularly wrong/bad/lame/etc. afaics for what it is
defined to do. (Like blank-embedded strings automagically parsed).

>> Not for everything or every purpose but useful for what it provides.
>
> I suppose it's possible it's just "not for me", yeah.

I consider it somewhat like "GOTO" -- not for mass consumption, perhaps,
but sometimes quite useful.

--

Karl E. Peterson

unread,
Nov 19, 2009, 6:16:31 PM11/19/09
to

I'm trying really hard to recall my distaste. It was developed in the GW-BASIC
years, early-80s maybe. Maybe even earlier. I guess I never saw the utility of it,
or just knew how to do whatever I needed with Print, so it wasn't something I ever
grew to find a use for either. Ah well, yeah, nothing particularly
wrong/bad/lame/etc other than the confusion it seems to cause in threads like this.
<g>

dpb

unread,
Nov 19, 2009, 7:12:03 PM11/19/09
to
Karl E. Peterson wrote:
...
> I'm trying really hard to recall my distaste. ...

Probably related to the fact that it would delimit all strings, etc.,
which can make text files somewhat "messy" if don't need them and
similar rules that one could see as "obsessively compulsive".

The thing is, of course, that by utilizing those rules one handles the
not-so-easy cases of the embedded blanks and similar w/o parsing as a
payback.

I suppose I never developed an aversion because most of what I did w/
any dialect of BASIC (which also goes wayback on a multitude of systems)
used machine-only files and the rules were such that it was simple
enough to move from HP85 or similar to ROM dialects on standalone Z80
boards as well as CP/M and/or MSDOS that way.

--

Karl E. Peterson

unread,
Nov 19, 2009, 7:28:01 PM11/19/09
to
dpb wrote:
> Karl E. Peterson wrote:
> ...
>> I'm trying really hard to recall my distaste. ...
>
> Probably related to the fact that it would delimit all strings, etc.,
> which can make text files somewhat "messy" if don't need them and
> similar rules that one could see as "obsessively compulsive".

I'm sure that's it, yeah. If I wanna delimit, *I* delimit! :-)

Ralph

unread,
Nov 19, 2009, 8:12:38 PM11/19/09
to

"Karl E. Peterson" <ka...@exmvps.org> wrote in message
news:OidoqLWa...@TK2MSFTNGP04.phx.gbl...

Just in case someone relatively new might be following this thread, it
should be mentioned that just because Print may be considered more useful
and thus more recommended, going into an existing application and
willy-nilly replacing Writes with Prints is not a good idea - as some newbie
I'm close to quickly found out. I, huh ... rather he, wasted quite a few
days answering the phone and putting everything back.

-ralph


Dee Earley

unread,
Nov 20, 2009, 4:14:26 AM11/20/09
to
On 19/11/2009 18:50, Karl E. Peterson wrote:
> Dee Earley wrote:
>> On 19/11/2009 16:31, Tony Girgenti wrote:
>>> Hello.
>>>
>>> I'm using VB6 to create an output file.
>>>
>>> Is there a way to simply output a line to the file with just a form feed
>>> character(CHR(10) in it? No carriage return/line feed. Just a formfeed
>>> character.
>>
>> Use Write #
>>
>> Print # is for line based/formatted data.
>
> Wrong.

My apologies, it shows how long ago I last used them...
And I misread MSDN:
Write # Statement: Writes data to a sequential file.
Print # Statement: Writes display-formatted data to a sequential file.

Next time Karl, you may want to try elaborating slightly :)

Tony Girgenti

unread,
Nov 20, 2009, 8:45:03 AM11/20/09
to
Hello Nobody.

Your suggestion worked exactly the way i wanted it to. Thanks for your reply.

Jeff Johnson was right. It's a 12 not a 10.

Thanks for all of the other replies.

Tony

"Nobody" wrote:

> .
>

Karl E. Peterson

unread,
Nov 20, 2009, 6:32:22 PM11/20/09
to
Dee Earley brought next idea :

> Next time Karl, you may want to try elaborating slightly :)

Hey, consider it a sign of respect, in that I knew you knew how to
remember yourself. ;-)

--
[.NET: It's About Trust!]


0 new messages