Beginning Programmer needs a little help
-
Greetings, I am working on a project that is way to big for me, but I thought I would try and tackle it anyway as an opportunity to learn more. Within my application I am trying to develop a static method that I can use to convert a time such as 1:15 (1 hour 15 minutes) to a decimal. I understand the formula, since I used it in Excel before. I need to take the input value from the user, pass it to the method, and multiply it by 24. This will give me the decimal value that I need. My question is strangly simple, and I am still just stumped by it... what data type do I need to use to get my user information into my method? It's just the colon in the user value that throws me off. Can I just take in "xx:xx" as a string value and then use "Convert.ToDecimal"? I'm sorry if I am not clear enough. If it's not, let me know and I will be happy to rephrase.
Beginning Programmer - Still learning as much as possible.
-
Greetings, I am working on a project that is way to big for me, but I thought I would try and tackle it anyway as an opportunity to learn more. Within my application I am trying to develop a static method that I can use to convert a time such as 1:15 (1 hour 15 minutes) to a decimal. I understand the formula, since I used it in Excel before. I need to take the input value from the user, pass it to the method, and multiply it by 24. This will give me the decimal value that I need. My question is strangly simple, and I am still just stumped by it... what data type do I need to use to get my user information into my method? It's just the colon in the user value that throws me off. Can I just take in "xx:xx" as a string value and then use "Convert.ToDecimal"? I'm sorry if I am not clear enough. If it's not, let me know and I will be happy to rephrase.
Beginning Programmer - Still learning as much as possible.
Hi, if the method is to accept a date, you basically have two choices: - pass it a DateTime instance - pass it a string representing a date, and use DateTime.Parse inside the method to decode it whatever you choose the method will need DateTime.Hours and DateTime.Minutes to calculate the integer value you want. I don't expect Decimal type will be of much help. :)
Luc Pattyn [Forum Guidelines] [My Articles]
Happy 2008!
-
Hi, if the method is to accept a date, you basically have two choices: - pass it a DateTime instance - pass it a string representing a date, and use DateTime.Parse inside the method to decode it whatever you choose the method will need DateTime.Hours and DateTime.Minutes to calculate the integer value you want. I don't expect Decimal type will be of much help. :)
Luc Pattyn [Forum Guidelines] [My Articles]
Happy 2008!
Thank you very much! I really appreciate it!
Beginning Programmer - Still learning as much as possible.