Using Str$ to convert integers

Using Str$ to convert integers

Anonymous
Not applicable
680 Views
7 Replies
Message 1 of 8

Using Str$ to convert integers

Anonymous
Not applicable
I have this simple code:

Str$(iVertex + 1)

Say that iVertex is 29....

The string returned from this call is " 30"

Why am I getting the space before the number in the string?

It should be "30"

This happenes for all of the values that I attempt to convert into strings.

Thanks for any help.

Andrew
0 Likes
681 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable
Trim(Str$(iVertex + 1))

wrote in message news:5192291@discussion.autodesk.com...
I have this simple code:

Str$(iVertex + 1)

Say that iVertex is 29....

The string returned from this call is " 30"

Why am I getting the space before the number in the string?

It should be "30"

This happenes for all of the values that I attempt to convert into strings.

Thanks for any help.

Andrew
0 Likes
Message 3 of 8

Anonymous
Not applicable
From the elusive Help file for Str Function:
Remarks

When numbers are converted to strings, a leading space is always reserved
for the sign of number. If number is positive, the returned string contains
a leading space and the plus sign is implied.

Use the Format function to convert numeric values you want formatted as
dates, times, or currency or in other user-defined formats. Unlike Str, the
Format function doesn't include a leading space for the sign of number.

:-)

wrote in message news:5192291@discussion.autodesk.com...
I have this simple code:

Str$(iVertex + 1)

Say that iVertex is 29....

The string returned from this call is " 30"

Why am I getting the space before the number in the string?

It should be "30"

This happenes for all of the values that I attempt to convert into strings.

Thanks for any help.

Andrew
0 Likes
Message 4 of 8

Anonymous
Not applicable
Or use
Trim(Str(iVertex +1))
--
Saludos, Ing. Jorge Jimenez, SICAD S.A., Costa Rica


"Jeff Mishler" wrote in message
news:5193166@discussion.autodesk.com...
From the elusive Help file for Str Function:
Remarks

When numbers are converted to strings, a leading space is always reserved
for the sign of number. If number is positive, the returned string contains
a leading space and the plus sign is implied.

Use the Format function to convert numeric values you want formatted as
dates, times, or currency or in other user-defined formats. Unlike Str, the
Format function doesn't include a leading space for the sign of number.

:-)

wrote in message news:5192291@discussion.autodesk.com...
I have this simple code:

Str$(iVertex + 1)

Say that iVertex is 29....

The string returned from this call is " 30"

Why am I getting the space before the number in the string?

It should be "30"

This happenes for all of the values that I attempt to convert into strings.

Thanks for any help.

Andrew
0 Likes
Message 5 of 8

Anonymous
Not applicable
Right, that's what joeparker said, too. I was merely answering Andrew's
question of "Why does it do it" with a quote from a source he could have
looked up just as easily as I did........
:-)

"Jorge Jimenez" wrote in message
news:5193221@discussion.autodesk.com...
Or use
Trim(Str(iVertex +1))
--
Saludos, Ing. Jorge Jimenez, SICAD S.A., Costa Rica
0 Likes
Message 6 of 8

Anonymous
Not applicable
Sorry Jeff, I did not see JoeParkers post.

--
Saludos, Ing. Jorge Jimenez, SICAD S.A., Costa Rica


"Jeff Mishler" wrote in message
news:5193222@discussion.autodesk.com...
Right, that's what joeparker said, too. I was merely answering Andrew's
question of "Why does it do it" with a quote from a source he could have
looked up just as easily as I did........
:-)

"Jorge Jimenez" wrote in message
news:5193221@discussion.autodesk.com...
Or use
Trim(Str(iVertex +1))
--
Saludos, Ing. Jorge Jimenez, SICAD S.A., Costa Rica
0 Likes
Message 7 of 8

Anonymous
Not applicable
Thanks to everyone for their comments, answers, gripes etc..

Much appreciated.

Andrew
0 Likes
Message 8 of 8

Anonymous
Not applicable
Skip the Trim and change your Str$ function to CStr and you get no spaces
...


wrote in message news:5193393@discussion.autodesk.com...
Thanks to everyone for their comments, answers, gripes etc..

Much appreciated.

Andrew
0 Likes