Solved

Masked Edit Control format

Posted on 2000-04-26
7
1,473 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
  • 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Some time ago I was asked to create a VBA function that would calculate a check digit for an input number, using the following procedure: First, sum up all the individual digits in the number If that sum value has more than one digit, then sum up …
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This video walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

708 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now