Not sure which code to use

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,226
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 calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
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
Thanks,
I will leave it as it is then.
Have a nice day
 
Upvote 0

Forum statistics

Threads
1,214,579
Messages
6,120,365
Members
448,956
Latest member
Adamsxl

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