|
Difference between two dates .(MM/DD/YY)
One date is given through Textbox are in the same format as System date.
Other is just system date .
I want to get date,month,year differences
|
|
|
|
|
The right way to do this is by converting to two DateTime objects, then apply
whatever it is you need, e.g. subtract to get a TimeSpan.
You should not operate on date strings yourself, use TryParse() instead.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
What Luc said, plus:
Don't use TextBoxes for dates, use a DateTimePicker.
Use ISO 8601-compliant formats -- YYYY-MM-DD.
|
|
|
|
|
I'm trying to BitBlt a portion of an image to another but all I get is the background color of the source bmp! Any ideas?
may your code be error free.
(okay, maybe two lines.)
|
|
|
|
|
The code that you have written is incorrect.
If you show the code, you may have a chance of getting a more specific analysis.
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
I have had this happen to me when I use the WinAPI BitBlt method. What I had to do is make a call to CreateCompatibleDC[^], then copy the bitmap to that DC, and finally use BitBlt from the resulting DC. Without seeing any of your code, I have NO idea if this will help, but my guess is that it might.
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
Hello,
anyone knows if there is a configuration framework available which provides saving of configuration and edit the configuration in an graphical editor..
Best regards
Hansjörg
|
|
|
|
|
|
Hello,
I search some configuration framework with which I can make application configuration. Edit inside the application, load and save a new configuration. The property grid is for sure usefull to make such a framework, but it is only a part of it...
Til now I have found NINI which looks good. But it provides only to part of saving and loading...I search also the part of the graphical representation of the configuration data.
Best regards
Hansjörg
|
|
|
|
|
How do I go about getting 24bit audio to play using directSound? 8 and 16 bit audio plays fine, but when ever I go to play 24 bit audio, my program throws an 'Value does not fall within the expected range.' exception on:
sound = new SecondaryBuffer(dataGridResults.CurrentRow.Cells[3].Value.ToString(), d, dSound);
The creation and initialization:
private Device dSound;<br />
private SecondaryBuffer sound;<br />
private BufferDescription d = new BufferDescription();<br />
<br />
dSound = new Device();<br />
dSound.SetCooperativeLevel(this, CooperativeLevel.Priority);<br />
d.LocateInHardware = true;<br />
<br />
d.ControlPan = true;<br />
d.ControlVolume = true;<br />
d.ControlFrequency = true;<br />
d.ControlEffects = true;<br />
d.GlobalFocus = true;<br />
How do I fix this?
|
|
|
|
|
Is the file a Wav or an MP3?
|
|
|
|
|
The file is a wav recorded at 44100.
|
|
|
|
|
I remember reading something about this a loooooooong time ago, but I can't remember what and I can't for the life of me remember where. Bear with me while I try and see if I can dig it up.
One other question, does the DirectX sample application (included with the DX SDK) do the same thing when you try and play the file?
|
|
|
|
|
Thanks for any help you can give.
I tried the file in several of the sample applications, and they all give 'File to large. You should stream large files'. However, I get this message even with files that play correctly in my app.
|
|
|
|
|
I'm running into exactly the same problem here and I haven't worked it out yet.
Did you get anywhere with this?
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
I created a brand new project and open clissview diagram window. Then i added 2 class Person and Employee i want to add the inhertiance line to show the relationship but visual studio doesn't let me to drag and drop the inhertance symbol from the toolbox window.
I know If i create these two classes then i will automatically but i want to create class diagram first then actually creating classes.
Any help thanks
|
|
|
|
|
Don't drag and drop it, just click the inheritance tool and your cursor will now change on the designer. You then click on the child class and you will see a line start to draw. You finally click on your base class and the inheritance has thus been completed.
Hope that helped.
Also, quick question. Shouldn't the employee just be an enum of PersonType?
|
|
|
|
|
|
Hello,
I'm trying to eliminate a huge switch() block in my code by the use of Reflection. I added a dictionary to the class, and then tried populating it in a static constructor. The goal is that later I'll simply get delegates from this dictionary and use DynamicInvoke on them, which would replace the switch.
An example of what I'm trying to do:
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
ClassA a = new ClassA();
}
}
class ClassA
{
static ClassA()
{
foreach (MethodInfo mi in typeof(ClassA).GetMethods(BindingFlags.Instance | BindingFlags.NonPublic))
if (mi.ReturnType == typeof(UInt16))
{
ParameterInfo[] pis = mi.GetParameters();
if ((pis[0].ParameterType == typeof(String).MakeArrayType()) &&
(pis[1].ParameterType == typeof(Byte).MakeArrayType()) &&
(pis[2].ParameterType == typeof(Byte).MakeArrayType().MakeByRefType()) &&
(pis[2].IsOut))
{
CallbackMethods.Add(mi.Name, Delegate.CreateDelegate(typeof(CallbackMethodDelegate), mi));
}
}
}
private static Dictionary<string, delegate=""> CallbackMethods = new Dictionary<string, delegate="">();
private delegate UInt16 CallbackMethodDelegate(String[] header, Byte[] mgedDataIn, out Byte[] mgedDataOut);
private UInt16 Method1(String[] header, Byte[] mgedDataIn, out Byte[] mgedDataOut)
{
mgedDataOut = null;
return (UInt16)0;
}
}
}</string,></string,>
Executing this code gives me a TypeInitializationException when running the Delegate.CreateDelegate() method.
This is undoubtedly linked to the fact that I want to invoke instance methods, while the delegates are being created in a static constructor. In fact, if I copy and paste the code of my static constructor into an instance constructor, make the dictionary an instance variable, and call a different overload of CreateDelegate (the one that receives firstArgument, since I now have this ) it works.
So my question would be: is there a way to create these delegates in the static constructor, and then later when calling DynamicInvoke on them, bind them to the correct instance of the class?
Thanks in advance for any suggestions you can offer.
Leonardo Pelisoli
|
|
|
|
|
Instead of making a dictionary of method name to a delegate, why not make it a dictionary from name to method info? Then, just call the method later using reflection by calling MethodInfo.Invoke().
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
Skippums,
Thanks for your suggestion. I've indeed done as you said one time before, and it works. However, as far as I understand it, reflection done in this fashion is very slow when compared to a normal method call.
In this part of the application, I can't really afford the performance loss. That leaves me with delegates as my only choice since they are, as I understand it, much faster than reflection.
Leonardo Pelisoli
|
|
|
|
|
It is my understanding that delegates are by design bound upon creation. Therefore, you either need to have the object being bound in your static constructor, or you need to use reflection.
Another alternative that may help is a hybrid of the two, where you would add a value to the dictionary so you keep BOTH the delegate AND the method info. Then, whenever you call the method that needs to use the delegate, check if the delegate is null, and if so, bind the delegate at that time and save it in the dictionary. Since dictionary lookup is an O(1) operation, the only noticable performance penalty would occur the first time you called the method. Alternatively, you could do this work in the instance constructor for the class, which would eliminate the slight overhead in the methods that use the information. Anyway, let me know if this will work for you.
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
Skippums,
I ended up filling the dictionary in the instance constructor of the class, as you said, so that I can bind the delegates at that time. It works!
Thanks a lot for your help.
Leonardo Pelisoli
|
|
|
|
|
Hello,
Is there any way to disable the scrollwheel function for a ComboBox?
Thanks
R.Myers
|
|
|
|
|
The combobox has a MouseWheel event but it appears to have no way of altering the data (the properties are all read only) or cancelling.
You may have to invesigate in the API: WM_MOUSEWHEEL[^]
|
|
|
|