Lost Password?

  #1 (permalink)  
Old 09-11-2007, 06:21 AM
travy92's Avatar   
travy92 travy92 is offline
Learning Programmer
 
Join Date: Sep 2007
Location: Australia
Age: 15
Posts: 71
Rep Power: 4
travy92 is on a distinguished road
Send a message via MSN to travy92
Post Tutorial - Date Calculator!

Welcome to this very simply date calculator!

What we're doing!

Basically we'll be making a program that calculates the date difference between the two dates specified!

GUI (LAYOUT):
This is my GUI:



----------------------------------------------------------------

What you need~
1 Command Button with:
Name: cmdCalc
Caption: Calculate!

1 ListBox with:
Name: lstAnswer

----------------------------------------------------------------
CODE (Very short & simple!)

Add this code into General Declarations before you begin adding the rest of the code:

Quote:
Private Mint As Integer
----------------------------------------------------------------

Then add this code:

Quote:
Private Sub cmdCalc_Click()
Mint = DateDiff("d", "5/09/2007", "11/09/2007")
lstAnswer.AddItem "The day difference = " & Mint
End Sub
----------------------------------------------------------------

Code Explanation:

Quote:
Private Sub cmdCalc_Click()
Basically means whenever you click on the cmdCalc button ("Calculate!" button), do the code that's specified below the line.

----------------------------------------------------------------

Quote:
Mint = DateDiff("d", "5/09/2007", "11/09/2007")
Means calculate the day difference between the dates specified.

----------------------------------------------------------------

Quote:
lstAnswer.AddItem "The day difference = " & Mint
Simply means add the answer to the LixtBox.

----------------------------------------------------------------

You can also change this:
Quote:
Mint = DateDiff("d", "5/09/2007", "11/09/2007")
The "d" can be changed into other things like:

Year(s): "yyyy"
Month(s): "m"
Week(s): "ww"
Day(s): "d"
Hour(s): "h"
Minute(s): "n"
Second(s): "s"

Just replace the "d" with one of those and you're done!

ALSO you can obviously change the dates to whatever you want!

Thanks to Tcm9669 for the Screenshot program.

Thanks to TheComputerMaster for the upgraded Screenshot program.

Thanks to you for reading this tutorial!

Made by me, Travy92.


Lol, Samples!:
Attached Files To view attachments your post count must be 1 or greater. Your post count is 0 momentarily.
__________________
Quote:
The pacifist's task today is to find a method of helping and healing which provides a revolutionary constructive substitute for war.

Last edited by Jordan; 09-11-2007 at 08:17 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 11-30-2007, 03:09 AM
Hybrid Hybrid is offline
Newbie
 
Join Date: Nov 2007
Posts: 1
Rep Power: 0
Hybrid is on a distinguished road
Default

thhhxx for this tutorial
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 12-27-2007, 02:39 PM
$RaMRoM$ $RaMRoM$ is offline
Newbie
 
Join Date: Oct 2007
Posts: 6
Rep Power: 0
$RaMRoM$ is on a distinguished road
Default

Thanks a lot travy92, your tuts are wonderful, BTW i just wanna say that maybe you can add Text Boxes and change:
Code:
Private Sub cmdCalc_Click()
Mint = DateDiff("d", "5/09/2007", "11/09/2007")
lstAnswer.AddItem "The day difference = " & Mint
End Sub
To:
Code:
Private Sub cmdCalc_Click()
Mint = DateDiff("d", Val(Text1.Text), Val(Text2.Text))
lstAnswer.AddItem "The day difference = " & Mint
End Sub
Just Saying! lol
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 05-01-2008, 09:04 AM
Kamilo23 Kamilo23 is offline
Newbie
 
Join Date: May 2008
Posts: 1
Rep Power: 0
Kamilo23 is on a distinguished road
Default Re: Tutorial - Date Calculator!

thx for tutorial!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 05-02-2008, 11:11 AM
Xav's Avatar   
Xav Xav is offline
Guru
 
Join Date: Mar 2008
Location: London, England
Posts: 3,001
Last Blog:
Piano Exam
Rep Power: 26
Xav is a name known to allXav is a name known to allXav is a name known to allXav is a name known to allXav is a name known to allXav is a name known to all
Send a message via MSN to Xav
Default Re: Tutorial - Date Calculator!

Quote:
Originally Posted by $RaMRoM$ View Post
Thanks a lot travy92, your tuts are wonderful, BTW i just wanna say that maybe you can add Text Boxes and change:
Code:
Private Sub cmdCalc_Click()
Mint = DateDiff("d", "5/09/2007", "11/09/2007")
lstAnswer.AddItem "The day difference = " & Mint
End Sub
To:
Code:
Private Sub cmdCalc_Click()
Mint = DateDiff("d", Val(Text1.Text), Val(Text2.Text))
lstAnswer.AddItem "The day difference = " & Mint
End Sub
Just Saying! lol
I'm not sure your code will work. DateDiff() expects 3 string parameters, yet Val() returns a value. Maybe a DateTimePicker would be a better choice of control.
__________________
Xav, the power of youth
Worship the Creator... not his creations
Web Site | Beta Site
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
A date showing tutorial ahsan16 VB Tutorials 2 03-15-2007 09:08 AM
John's Java Tutorial Index John Java Tutorials 0 01-11-2007 03:05 PM
PHP:Tutorial The Date John PHP Tutorials 0 01-10-2007 06:10 PM
Flex, bison multifunction calculator annatsos C and C++ 1 01-04-2007 06:00 AM


All times are GMT -5. The time now is 06:11 PM.

Contest Stats

John ........ 87.50000
dargueta ........ 75.00000
Xav ........ 50.00000
MeTh0Dz ........ 20.00000
gaylo565 ........ 18.00000
Johnnyboy ........ 3.00000

Contest Rules

Ads