Not sure which code to use

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,731
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

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
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,223,885
Messages
6,175,183
Members
452,615
Latest member
bogeys2birdies

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