Hi
How can I convert the total minutes into hour minutes.
ex:
Total minutes : 209
I want it should display : 3 hours 29 minutes
thanks
asm
Printable View
Hi
How can I convert the total minutes into hour minutes.
ex:
Total minutes : 209
I want it should display : 3 hours 29 minutes
thanks
asm
Note that that will only be correct if the total time is less than 24 hours. If you want to handle times greater than that then do this:vb.net Code:
Dim time As TimeSpan = TimeSpan.FromMinutes(209) MessageBox.Show(String.Format("{0} hours {1} minutes", _ time.Hours, _ time.Minutes))vb.net Code:
Dim time As TimeSpan = TimeSpan.FromMinutes(209) MessageBox.Show(String.Format("{0} hours {1} minutes", _ Math.Floor(time.TotalHours), _ time.Minutes))
thanks for your quick help
How can I display the total minutes - get from textbox1
display in textbox2 with hour minutes
vb Code:
Dim TotalMinutes As Double TotalMinutes = Val(TextBox1.Text) Dim ShowTime As TimeSpan = TimeSpan.FromMinutes(TotalMinutes) TextBox2.Text = ShowTime.Hours + ShowTime.Minutes MessageBox.Show(String.Format("{0} hours {1} minutes", ShowTime.Hours, ShowTime.Minutes))
I have no idea what you just asked for.
Does that not work?
it work but it show in message box,
but i want it will show in textbox like 3:29
thanks
:rolleyes: You really should apply some thought to the problem before asking for help. You display a string in a MessageBox like this:You display a string in a TextBox like this:vb.net Code:
MessageBox.Show(myString)I've shown you how to create the string you want and I used the MessageBox to show it as an example. If you want to show the string in a TextBox instead then by all means do so. You already know how to create the string so you can do whatever you want with it.vb.net Code:
myTextBox.Text = myString
thanks...
I achive the result using code:
vb Code:
TextBox2.Text = ShowTime.Hours.ToString + ":" + ShowTime.Minutes.ToString
Why not use the String.Format method like I showed you:Note that I've also specified that the minutes be displayed with two digits with "{1:00}". Using your code if the minutes are not double figures you'd end up with a string like "3:9" instead of "3:09". That said, you could still use code like yours to get double-digit minutes if you use ShowTime.Minutes.ToString("00").vb.net Code:
TextBox2.Text = String.Format("{0}:{1:00}", ShowTime.Hours, ShowTime.Minutes))