|
-
February 15th, 2007, 09:43 AM
#1
Str function in VB
Hi,
I'm a beginner in VB. I tried to change an integer to string using str as below
Dim z As Integer
Dim s As String
z = 100
s = Str(z)
Combo2.AddItem (s)
when 100 is converted to string there is a space added in the start of the string.
it is " 100" instead of 100. Please let me know if there are any other functions for changing integer 100 to "100"
Regards,
Carol.
-
February 15th, 2007, 10:06 AM
#2
-
February 15th, 2007, 10:37 AM
#3
Re: Str function in VB
I believe this is the correct syntax:
Dim z As Integer
Dim s As String
z = 100
s = CStr(z)
If kids were left to their own devices, would they ever come up with a thing like war?......The Wheel / Todd Rundgren
Do canibals not eat clowns because they taste funny? 
-
February 15th, 2007, 12:42 PM
#4
Re: Str function in VB
Right.
The str() function takes in account that there might be a negative number, preceded by a '-'. Str() precedes positive numbers with a blank and will thus result in equal length strings to positive and negative numbers. (Str(-100) has the same length as str(100))
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|