The value we see above is Date which is stored in variable B but when we press ok we see the data type of the above value. Step 5: Now let us display both the value and data type of variable B as follows. Step 4: Now convert the date value in A as a string using CSTR function and store the value in variable B as shown below. Step 3: Store a date in Variable A as follows. Step 2: Two variables need to declare one as Date data type and another as a string as shown in the image below. Step 1: The third macro name can be as follows. We will convert a date data type value to string. Follow the below steps to use CSTR function in Excel VBA. Now let us try a complex data type which is Date data type. The value stored in variable B is 255 which should be an integer but let us see what we get as the data type for variable B, We converted value 255 which was an integer as a string using CSTR function. Step 6: Run the code by hitting F5 or Run button and see the output. Step 5: Let us display the value of variable B as well as the data type of variable B as follows. Step 4: Now in Variable B convert A to a string using the CSTR function as shown below. ![]() Step 3: Store any random value in Variable A, keep in mind it is integer data type, so provide an integer value as follows. Step 2: Declare two variables one as integer and another as a string. Step 1: Write another macro name as follows in the same module. Now let us convert the very basic data type which is an integer in the same way above. Follow the below steps to use CSTR function in Excel VBA. Though A had a Boolean value in it we converted it to String using the CSTR function. Now let us see the data type for variable B. The value stored in B is the value of A which is “TRUE”. Step 9: Re-run the above code and see the last two result as follows. Step 8: Now display both the data type of variable B and the value stored in B using the message box function as follows. We defined another variable and store the value of A converting it to a string using CSTR function. Step 7: Right now the data type for the variable A is Boolean now let us change it to a string using VBA CSTR function as follows. Step 6: Run the code by hitting F5 or Run button and see the output. Step 5: Let us first display the data type of the variable A using the TypeName Function as follows. Step 4: Declare a variable as data type as Boolean and store value true in it. Step 3: Double click on the module and let’s begin our macro with a name as shown below. ![]() Step 2: In the VBA editor insert a module from the reference to the screenshot below.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |