1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Help with calculating time differences

Discussion in 'Visual Basic ( VB )' started by CJW, Nov 20, 2009.

  1. CJW

    CJW New Member

    Joined:
    Nov 20, 2009
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    I'm building a program to calculate the cost of hiring a trip and need to calculate the waiting time.

    How can I do this from the two text boxes where you input the numbers. The two textboxes are:

    txtTimeOfArrival
    txtTimeOfReturn

    I need the difference in minuets, the input is HH : MM

    Please reply quick it's for my A level work and my teacher doesn't know!!!
     
  2. Cseek

    Cseek New Member

    Joined:
    Dec 1, 2009
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    train driver
    Location:
    hubli / karnataka
    Home Page:
    dim timeOne as variant 'or use date
    dim timeTwo as variant ' or use date
    dim waitedtime as long

    if not yourtextbox.text = "" or not yourtextbox2.text = ""
    then
    timeone = format(yourtextbox.text,"dd/mm/yy hh:nn")
    timetwo = format(yourtextbox2.text,"dd/mm/yy hh:nn")

    waitedtime = datediff("n",timeone,timetwo)

    else
    waitedtime = "you have entered invalid time format text "
    end if

    when ever you are using dates , when your text box lost the focus
    immediately you should cross check the value you entered is in proper date/time format;
    hence better use any calender control or else
    use any function to cross check it.
     

Share This Page