By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,419 Members | 1,394 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,419 IT Pros & Developers. It's quick & easy.

2 textbox's converting to a timevalue

P: n/a
Hi!

I have a logical problem. How can I convert 2 textboxvalues,(one for hours
and one for minutes) to a common value type of float or double. I wish to
save this new value in a database

Any help appreciates

--- < Hans > ---
Nov 16 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
I'm not sure if I understand your question correctly, but if you simply want to
store a single value in the database, why not store it in units of minutes?

You can convert the text in the hours box into minutes, and then add the value
from the minutes box to obtain the overall value.

int hours = int.Parse(hoursTextBox.Text);
int minutes = int.Parse(minutesTextBox.Text);

int totalMinutes = (hours * 60) + minutes;

For something like this, you could use ints instead of doubles (assuming you
don't have to deal with fractional hours/minutes.)

To recreate the values you simply do this:

int hours = totalMinutes / 60;
int minutes = totalMinutes % 60;

If the two textbox values can contain any number of hours and minutes, like 546
hours and 345 minutes, you might want to store the two values separately to be
able to get the original values back.

Hope this helps.

--
Rodger Constandse

<http://www.SequenceDiagramEditor.com>
Sequence Diagram Editor - A quick and easy way to draw and edit sequence diagrams

Hans [DiaGraphIT] wrote:
Hi!

I have a logical problem. How can I convert 2 textboxvalues,(one for hours
and one for minutes) to a common value type of float or double. I wish to
save this new value in a database

Any help appreciates

--- < Hans > ---

Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.