|
TimeSpan ts = dateTime1 - dateTime2;
Console.WriteLine(ts.TotalHours);
|
|
|
|
|
You should look into the TimeSpan object.
TimeSpan timeSpan = DateTime.Now.Subtract(new DateTime(2008, 10, 3));
To get the whole number of hours, its as simple as int hours = timeSpan.Hours
If you want to get the total hours, double totalHours = timeSpan.TotalHours
If you're unclear on any of this I recommend taking a look at the documentation or doing a google search on System.TimeSpan
|
|
|
|
|
Have been trying up an easy program, but now want to try make it more user friendly by maybe playing a song in the background. How can I go about this one.Anyone help please.(C# base).
|
|
|
|
|
It depends on how you want to do it. The simplest way is:
System.Media.SoundPlayer soundPlayer = new System.Media.SoundPlayer();
soundPlayer.SoundLocation = @"c:\chord.wav";
soundPlayer.Play();
Don't forget to call soundPlayer.Dispose() when you're finished with it!
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Thanks alot that helped and am able to get through.could have kissed you if you were next to me.(just a jok)
Now check here, that method can only work with .wav file type only? or you can use other files(file size for a wav file is too large).
waiting....
Thanks alot
|
|
|
|
|
IT would have taken less time to change your code to point to an .mp3 file than it did to post the question here.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
You may be better off embedding media player. Right click on your toolbox and select Chose Items (you may have to wait a while for the next dialog!). Click on the COM Components tab and scroll down and select Windows Media Player.
Drag and drop (& resize) a WMP onto your form. Set the URL property to point to your file and you're done.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Sounds user hostile to me.
|
|
|
|
|
What's that supposed to mean?
|
|
|
|
|
The user may not want sound playing.
|
|
|
|
|
I have a program that allows the user to multi-select categories. The control is bound to a dataset table. When the user clicks the get data button, I have to pass the selected categories to a SQL Server stored procedure and limit products to the select categories.
The data is in a table in memory. I know I can loop through the rows of the data table and create some sort of a list and pass it as a varchar(max) parameter to the Store Procedure and parse it. Is there a more efficient method? A method that does not involve looping.
|
|
|
|
|
you are doing a your way thing i don´t imagine what it is.
i think you are using 1 varchar(max) column instead of 8 whatever columns.
you put all string in that varchar(max) and use "," to separate strings, isn´t thats right?!? so you need to loop to get them after.
i don´t use that, i add more columns and leave some empty if required, but you can do that don´t know if runs faster!
i heard of that in sql forum keep that way it´s ok to me.
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
************Programming Challenge**********************
Hi All
Again I have spent more than five hours but still fighting.
I just want to type underscore in my windows textbox.I am able to type characters, Hit enter key etc etc but do not yet found how to print underscore and other special characters like @,$,%,^
I have tried following code .Discovered new things but still trying to find the solution
SendKeys.SendWait(Keys.Decimal.ToString());
SendKeys.SendWait(Keys.S.ToString());
SendKeys.SendWait(Keys.A.ToString());
SendKeys.SendWait(Keys.N.ToString());
SendKeys.SendWait(Keys.D.ToString());
SendKeys.SendWait(Keys.E.ToString());
SendKeys.SendWait(Keys.Oem1.ToString());
SendKeys.SendWait(Keys.Oem102.ToString());
SendKeys.SendWait(Keys.Oem2.ToString());
SendKeys.SendWait(Keys.Oem3.ToString());
SendKeys.SendWait(Keys.Oem4.ToString());
SendKeys.SendWait(Keys.Oem5.ToString());
SendKeys.SendWait(Keys.Oem6.ToString()); // with this type of code getting Oem6 in
// textbox but i wanted 6.
SendKeys.SendWait(Keys.Oem7.ToString());
SendKeys.SendWait(Keys.Oem8.ToString());
SendKeys.SendWait(Keys.OemClear.ToString());
SendKeys.SendWait(Keys.OemBackslash.ToString());
SendKeys.SendWait(Keys.OemCloseBrackets.ToString());
SendKeys.SendWait(Keys.Oemcomma.ToString());
SendKeys.SendWait(Keys.OemMinus.ToString());
SendKeys.SendWait(Keys.OemOpenBrackets.ToString());
//with this code getting OemOpenBrackets in textbox but desired was (.
SendKeys.SendWait(Keys.OemPeriod.ToString());
SendKeys.SendWait(Keys.OemPipe.ToString());
SendKeys.SendWait(Keys.Oemplus.ToString());
SendKeys.SendWait(Keys.OemQuestion.ToString());
SendKeys.SendWait(Keys.OemQuotes.ToString());
SendKeys.SendWait(Keys.OemSemicolon.ToString());
SendKeys.SendWait(Keys.Oemtilde.ToString());
SendKeys.SendWait("{OemSemicolon}"); //givin error
SendKeys.SendWait(Keys.KeyCode== 106); //giving error
SendKeys.SendWait(Keys.E.ToString());
SendKeys.SendWait(Keys.P.ToString());
SendKeys.SendWait(Keys.U.ToString());
SendKeys.SendWait(Keys.K.ToString());
SendKeys.SendWait(Keys.A.ToString()); //working fine
SendKeys.SendWait(Keys.L.ToString());
SendKeys.SendWait(Keys.R.ToString());
SendKeys.SendWait(Keys.A.ToString());
SendKeys.SendWait(Keys.NumPad5.ToString()); //
//with this type of code getting NumPad5 in textbox desired was 5
SendKeys.SendWait(Keys.NumPad4.ToString());
SendKeys.SendWait("{Enter}"); //working fine
Any studymaterial ,sample application or anything related to this will help.I am also trying to find .
Thanks in advance
THE SK
I am the ONE
|
|
|
|
|
Hi All
Finally got it on below link
http://msdn.microsoft.com/en-us/library/8c6yea83(VS.85).aspx
The correct way is
SendKeys.SendWait("{+}"); //for typing plus
SendKeys.SendWait("{_}"); //for typing underscore
For this spent more than five hours ... great
THE SK
I am the ONE
|
|
|
|
|
Sandeep Kalra wrote: I just want to type underscore in my windows textbox.
Try using Fire_Fox. See it works I just_did_it. Oh wow, I did it again _ and again! Only took me like 5_seconds!
led mike
|
|
|
|
|
Hey led mike
U have used Fire_Fox.I think u should use Fire_Lion now.It will take 50 years to you
|
|
|
|
|
Programattically... Using C#...
|
|
|
|
|
You can't just append the character to the text?
|
|
|
|
|
Hi all,
I'm testing an application by writing bitmaps to a temporary file. I thought it would be neat to have an application that monitors this file and updates its picture whenever the file changes.
I use FileInfo to get the last write time, and if it's changed, I make a new Bitmap with the file's contents and display it. The file is never opened. Sounds simple.
The problem is the system thinks the file is in use, and won't let me overwrite it. It says: "The process cannot access the file because it is being used by another process." But I never open the file, and just use it temporarily to get the last write time and make a bitmap.
How can I make Windows realize the file isn't being used in between samples?
Here's the relevant code:
public void monitorFile()
{
while (!Form1.done)
{
fi = new FileInfo(fname);
DateTime dt = fi.LastWriteTime;
if (lastWrite < dt)
{
lastWrite = dt;
parent.showBitmap (new Bitmap(fname));
}
fi = null;
Thread.Sleep(3000);
}
}
Thanks!
Alan
|
|
|
|
|
Alan Balkany wrote: The process cannot access the file because it is being used by another process.
Maybe this "another process" is you! Always make sure you closed all opened files in your project.
While (true) { Human.isLearnable = true; }
|
|
|
|
|
But the file is never explicitly opened. It's hard to close a file that was never opened.
|
|
|
|
|
Maybe you have some problem with Vs and/or Windows or even vise versa!
While (true) { Human.isLearnable = true; }
|
|
|
|
|
Hey, you didn't close your file!
<blockquote class="FQ"><div class="FQA">Alan Balkany wrote:</div>public void monitorFile()
{
while (!Form1.done)
{
fi = new FileInfo(fname);
DateTime dt = fi.LastWriteTime;
if (lastWrite < dt)
{
lastWrite = dt;
parent.showBitmap (new Bitmap(fname));
}
fi = null;
Thread.Sleep(3000);
}
}</blockquote>
Add fi.Close(); before fi = null;
While (true) { Human.isLearnable = true; }
|
|
|
|
|
Your Bitmap object keeps the file open.
Try disposing the Bitmap object after you're done working with it.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Yes! You solved it! I just copied the bitmap to a new one and disposed the old one, and it worked! Thanks Mark!
|
|
|
|