Friday, October 6

The Print function of VB

Today I tried working with the Visual Basic for a while. The Print function gave me a headache for 20 minutes. The VB language is not well defined as C, and you can do a simple thing in several ways, andbut if you don't understand its style, you can't find any of the ways.

The first thing is to print some numbers in one line. In a loop, I used
Print i & " "
but each number is printed in one line. I checked the Print command carefully, and found I ignored the optional charpos in the commend:
charpos Optional. Specifies the insertion point for the next character. Use a semicolon (;) to position the insertion point immediately following the last character displayed. If charpos is omitted, the next character is printed on the next line.
So I changed the previous line as
Print i & " ";
and it works fine now.

Also, the Tab part of the command is tricky. In the documentation, you can use
{Spc(n) | Tab(n)} expression charpos
Tab(n) followed by expression. Common sense tells me I should be able to use it in this way:
Print i & Tab(1)
but failed.

In C language and Java language, "\n" means a new line. But in this Print function of VB, it doesn't work. You can get "slash n".

Labels:

1 Comments:

At October 07, 2006 8:32 AM, Anonymous Anonymous said...

"I tried the Visual Basic"-->a non-programer may have difficulty to understand this sentence very well. "I tried working with Visual Basic"

-- and, and, ... Too many "ands"

 

<< Home