Not sure which code to use

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,832
Office Version
  1. 2007
Platform
  1. Windows
Hi,
I had this in use the other day,
Code:
[COLOR=#333333]TextBox2.Value = Format(CDbl(Date), "dd/mm/yyyy")[/COLOR]

I was told that the CDbI was not needed so i put this in use.
Code:
TextBox2.Value = Format(Date, "dd/mm/yyyy")

Looking through some of my code i see this pop up in a few places so the thing is do i need to change / edit it or what,i dont even know what it does or doesnt do with regards the CDbI
Code:
TextBox1.Value = Format(CDbl(Date), "dd/mm/yyyy")

Can you advise please
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
CDbl is a function that converts a value to a double integer data type. Since the Date Constant is already a double interger data type, the CDbl function is not needed, but it does not hurt anything if it is there. You can delete it or leave it alone and the results are the same for the Format function. If the intent was to make the TextBox2 value a double then that would need to be done at the point in the code where that value is applied to something. But, more likely, the CDate funtion would be used than the CDbl. You can get a full read on the C conversion functions by opening the vbEditor and clicking the Help Icon. Then in the help search box, type 'Conversion Functions' and press Enter.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top