Solved

Masked Edit Control format

Posted on 2000-04-26
7
1,510 Views
Last Modified: 2008-03-03
Hi, can anyone tell me how to set the masked edit control format as short date format in Excel VBA?


I have VB. code as follows:

Private Sub DTPickerActual_Change()

MskEd4.Text = DateAdd("d", -4, DTPickerActual.Value)
MskEd10.Text = DateAdd("d", -10, DTPickerActual.Value)
MskEd30.Text = DateAdd("d", -30, DTPickerActual.Value)
MskEd60.Text = DateAdd("d", -60, DTPickerActual.Value)

End Sub

I can not tell what is wrong with this code.  In the Date/Time picker control property, I set format as 1-dtpShortDate.  And I checked the interval argument in DateAdd Founction, "d" is set as DAY.  But how come I will get both date and time in the masked edit text box?  I also try to put "y"  instead of "d", it remains the same.  Is there any setting I need to take care in the masked edit box properties?  I just want those masked edit boxes display the date not the time.

Thanks

Lisa
0
Comment
Question by:lisaswu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 9

Accepted Solution

by:
antrat earned 100 total points
ID: 2753809
Hi lisaswu

I suspect the problem is that default for the datepicker control value is time and date.
Try using:
MskEd4.Text = Format(DateAdd("d", -4, DTPickerActual.Value),"d/m/yy")
 
Or in the change Event for the MskEd textboxes place some code like this:


If ISDATE(MskEd4)then
 MskEd4=Format(MskEd4,"d/m/y")
End if

you can use any recognised format for the date i.e "m/d/yy", "m-d-yy", "dddd d mmm yyyy" etc



antrat
0
 

Author Comment

by:lisaswu
ID: 2753883
Hi Antrat,

I tried both codes, they did not work.  I got warning like : Can't find project or library, with "Format" highlighted.  

I don't know what's the default value of date time picker. But it doesn't display time but date in my case.

lisaswu

0
 
LVL 9

Expert Comment

by:antrat
ID: 2754193
Hi Lisaswu

If the keyword Format is giving an Error then you will need to install the libary for it. While in the VBE go to Tools>References then search through the "Available references" until you see one which is Pre-Fixed with the word "Missing" select it and you should see the File path in the frame below. then use the browse button to locate and open it. I THINK the file is something like icLabel.??

If you cannot see anything that is Pre-Fixed with "Missing" then run the code again so that you get the Error Message then hit De-bug and try again.


If Excel tells you that the Control or references is in use then delete the "Format" keyword(s) from your code save your file and then try.


You may also want to consider using the Calendar Control instead of Date/Time Picker You should be able to see this control in the "Available references" it's probaly called "Microsoft Calendar Control 8".


Good luck and let me know if you have any probs.

antrat
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:lisaswu
ID: 2770930
Hi Antrat,

Sorry for not replying your comment for so long.  I was out of town last couple few days.

I tried to install the library that were missing.  They were as follows:
Microsoft Active X Data Objects (Multi-dimensional)1.0 Library
Microsoft Active X Data Objects 2.1 library
Microsoft Active X Data Objects Recordsets 2.1 library

I was unable to install the first one, because there's no MSADOMD in my computer. What can I do with that?

By the way, I checked the available reference, there's no "Microsoft Calendar Control 8".

Thank you

Lisaswu
0
 

Author Comment

by:lisaswu
ID: 2770931
Adjusted points from 50 to 100
0
 

Author Comment

by:lisaswu
ID: 2829558
Hi Antrant,

Lately, we just upgraded our computers in the lab. I try your solution again.  It works.  Thank you very much.  And sorry for giving you the points this late.  You deserve it.

Lisa
0
 
LVL 9

Expert Comment

by:antrat
ID: 2830316
Thanks lisaswu

No problem, glad to help anytime :)

antrat
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

My experience with Windows 10 over a one year period and suggestions for smooth operation
Outlook for dependable use in a very small business   This article is about using the Outlook application (part of Microsoft Office) in a very small business, or for homeowners where dependability and reliability are critical requirements. This …
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question