Hello Shankar,

You can use Format() in VBA.

txttotser.Text = Format(txttotyrs.Value, "00") & Format(txttotmths.Value,
"00") & Format(txttotdays.Value, "00")

 

To use Application.Worksheetfunction.Text, it would go like:

txttotser.Text = Application.WorksheetFunction.Text(txttotyrs.Value, "00") &
Application.WorksheetFunction.Text(txttotmths.Value, "00") &
Application.WorksheetFunction.Text(txttotdays.Value, "00")

 

Also your calculator form left the year textbox blank when using the test
dates you suggested.  There should be a number in that box for the above
formula to generate zeroes for the year.  If you want to pad a string with
zeroes no matter if it's empty, a number, or something else; you could, like
this:

txttotser.Text = Right("00" & txttotyrs.Value, 2)

etc.

 

One more thing - I didn't study how you are calculating your date
difference, but VBA has a function called DateDiff for that purpose.  Check
VBA Help for more info.

Asa

 

From: excel-macros@googlegroups.com [mailto:excel-macros@googlegroups.com]
On Behalf Of Shankar Bheema
Sent: Sunday, January 29, 2012 10:02 PM
To: excel-macros@googlegroups.com; Sam Mathai Chacko
Subject: $$Excel-Macros$$ prefix 0 problem

 

Dear Experts

In the above attached file, there exists a worksheet containing total
service cell.  It takes the value from the userform data and saves on it.
when a single digit value comes in years or months or days textbox, it
should show prefixing 0.  

application.worksheetfunction.text(arg1,arg2),"interval as string"

is not working and throwing error.  Pls clarify.

-- 
FORUM RULES (986+ members already BANNED for violation)
 
1) Use concise, accurate thread titles. Poor thread titles, like Please
Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will
not get quick attention or may not be answered.
 
2) Don't post a question in the thread of another member.
 
3) Don't post questions regarding breaking or bypassing any security
measure.
 
4) Acknowledge the responses you receive, good or bad.
 
5) Cross-promotion of, or links to, forums competitive to this forum in
signatures are prohibited. 
 
NOTE : Don't ever post personal or confidential data in a workbook. Forum
owners and members are not responsible for any loss.
 
----------------------------------------------------------------------------
--------------------------
To post to this group, send email to excel-macros@googlegroups.com

-- 
FORUM RULES (986+ members already BANNED for violation)

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.

2) Don't post a question in the thread of another member.

3) Don't post questions regarding breaking or bypassing any security measure.

4) Acknowledge the responses you receive, good or bad.

5)  Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 

NOTE  : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.

------------------------------------------------------------------------------------------------------
To post to this group, send email to excel-macros@googlegroups.com

Reply via email to