Using CStr function in VB
CStr is a function that is used to convert data into the String data type. See the example below on how this CStr function can be used in Visual Basic programming.
Dim myData1 As Double '---Variable declaration
Dim myData2 As Boolean
Dim Output1, Output2 As String
myData1 = 5469.2641 '---Initialization of data
myData2 = False
Output1 = CStr(myData1) '--- convert data into String data type
Output2 = CStr(myData2)
MsgBox(Output1) '---Output is '5469.2641'
MsgBox(Output2) '---Output is 'False'
However, if a Date value is converted, the result will always be in short date format. Also note that if a Null value is being converted, a run-time error might occur. Hope that helps you understand how CStr function works and how you can apply it in your Visua Basic code.
See Also CType Function
Subscribe to:
Post Comments (Atom)

0 comments
Post a Comment