Solved

String to Time Calculations

Posted on 2007-08-06
10
185 Views
Last Modified: 2013-11-26
Hello Experts,
I have 3 combo boxes the are Hours (01 -24), Minutes (15, 30, 45) and Duration (15 - 120 in 15 increments). I need to combine Hours + Minutes to determine a Starting Time, obviously in Military time (ie 1330) and the add the duration to get Ending Time. This is a VB.Net CF app.

Thanks,

JackW9653
0
Comment
Question by:JackW9653
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 5

Expert Comment

by:Tertioptus
Comment Utility
So what exactly is your problem.
0
 

Author Comment

by:JackW9653
Comment Utility
I need a method to determine End Time by adding the Hour+Minute+Duration.
0
 
LVL 47

Accepted Solution

by:
Wayne Taylor (webtubbs) earned 250 total points
Comment Utility
Hello JackW9653,

Use something like this....

        Dim StartTime As Date = New Date(1, 1, 1, cbHours.Text, cbMinutes.Text, 0)
        Dim EndTime As Date = StartTime.AddMinutes(cbDuration.Text)
        MsgBox(EndTime.ToString("HHmm"))

Regards,

Wayne
0
 
LVL 47

Expert Comment

by:Wayne Taylor (webtubbs)
Comment Utility
Or, even shorter....

       Dim StartTime As Date = New Date(1, 1, 1, cbHours.Text, cbMinutes.Text, 0).AddMinutes(cbDuration.Text)
        MsgBox(EndTime.ToString("HHmm"))

Wayne
0
 

Author Comment

by:JackW9653
Comment Utility
Hi Wayne and thanks for the quick reply. Gets the "Implicit Conversion from 'String' to 'Integer' Error for the cbHours.text and cbMinutes.txt and "Implicit Conversion from 'String' To 'Double' for cbDuratation.txt
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 85

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 250 total points
Comment Utility
If you have Option Strict On then you will need to convert the values from your ComobBoxes into numeric values.

This can be done using CInt(), Integer.Parse(), etc...

    Dim StartTime As Date = New Date(1, 1, 1, Integer.Parse(cbHours.Text), Integer.Parse(cbMinutes.Text), 0).AddMinutes(Double.Parse(cbDuration.Text))

0
 

Author Comment

by:JackW9653
Comment Utility
Thanks IM, worked perfectly.
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
Comment Utility
Uhm...I just added Integer.Parse() and Double.Parse() to the code submitted by webtubbs....   =\
0
 

Author Comment

by:JackW9653
Comment Utility
Can I adjust the points then to give webtubbs some? Not sure how to go about doing that.
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
Comment Utility
You would have to post a request here for the question to be reopened so you can Split Points:
http://www.experts-exchange.com/Community_Support/General/

Then see this link for how to Split Points:
http://www.experts-exchange.com/help.jsp#hi69
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now