|
-
November 13th, 2008, 02:01 PM
#1
Does VBS have a to string method?
If it does not, how would I go about converting ints, doubles, longs, etc to a string? Thanks.
-
November 14th, 2008, 08:28 AM
#2
Re: Does VBS have a to string method?
Yes, VBScript has conversion methods for variable types.
- CBool() - Convert to Boolean Type
- CByte() - Convert to Byte Value
- CCur() - Convert to Currency Type
- CDate() - Convert to Date Value
- CDbl() - Convert to a Double Value
- CInt() - Convert to Integer Value
- CLng() - Convert to Long Integer Value
- CSng() - Convert to a Single Value
- CStr() - Convert to String Value
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
November 19th, 2008, 10:36 PM
#3
Re: Does VBS have a to string method?
Ok thanks.
What would happen if I used CDbl or CInt on a string without any numbers in it?
-
November 19th, 2008, 11:33 PM
#4
Re: Does VBS have a to string method?
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
November 22nd, 2008, 04:50 AM
#5
Re: Does VBS have a to string method?
 Originally Posted by dizou
Ok thanks.
What would happen if I used CDbl or CInt on a string without any numbers in it?
IMHO, you could test whether or not a number is present first, before converting it. - Call me old fashioned, but to me, it just makes a bit more sense.
-
November 22nd, 2008, 06:35 AM
#6
Re: Does VBS have a to string method?
 Originally Posted by PeejAvery
It should return 0.
Shouldn't it be type mismatch? To be honest I don't do VBS but they should be similar to VB6.0 and the following code raises an error.
Code:
Private Sub Command1_Click()
MsgBox CInt("x")
End Sub
-
November 22nd, 2008, 09:24 AM
#7
Re: Does VBS have a to string method?
 Originally Posted by dee-u
Shouldn't it be type mismatch?
Yes, it does. I was confusing it with an old basic language.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
November 22nd, 2008, 09:40 AM
#8
Re: Does VBS have a to string method?
 Originally Posted by PeejAvery
Yes, it does. I was confusing it with an old basic language.
Thanks for the clarification, in my part and for the OP's sake also.
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
|