Reputation: 867
CStr in VB script throws error when NULL value is passed to it, whereas CStr in VB.NET ignores null value and doesn't throw error.
Is there any other function which does same function as CStr in VB script.
Try
Dim str As String
str = Nothing
'assuming above line will set str to null.
Dim x As String
x = CStr(str)
' I am expecting CStr above should throw exception as it does in VBScript.
Catch ex As Exception
End Try
Thanks and Regards, PV
Upvotes: 0
Views: 1230
Reputation: 499042
Use ToString()
in order to get a string representation of an object.
This is invoked on the object itself:
MyVariable.ToString()
Note that for many objects this will return the type of the object - you need to give more details regarding what exactly you are trying to do and with what objects.
Upvotes: 1