thhhxx for this tutorial
Thread: 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:
----------------------------------------------------------------Private Mint As Integer
Then add this code:
----------------------------------------------------------------Private Sub cmdCalc_Click()
Mint = DateDiff("d", "5/09/2007", "11/09/2007")
lstAnswer.AddItem "The day difference = " & Mint
End Sub
Code Explanation:
Basically means whenever you click on the cmdCalc button ("Calculate!" button), do the code that's specified below the line.Private Sub cmdCalc_Click()
----------------------------------------------------------------
Means calculate the day difference between the dates specified.Mint = DateDiff("d", "5/09/2007", "11/09/2007")
----------------------------------------------------------------
Simply means add the answer to the LixtBox.lstAnswer.AddItem "The day difference = " & Mint
----------------------------------------------------------------
You can also change this:
The "d" can be changed into other things like:Mint = DateDiff("d", "5/09/2007", "11/09/2007")
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!:
Last edited by Jordan; 09-11-2007 at 05:17 AM.
thhhxx for this tutorial
Thanks a lot travy92, your tuts are wonderful, BTW i just wanna say that maybe you can add Text Boxes and change:
To:Code:Private Sub cmdCalc_Click() Mint = DateDiff("d", "5/09/2007", "11/09/2007") lstAnswer.AddItem "The day difference = " & Mint End Sub
Just Saying! lolCode:Private Sub cmdCalc_Click() Mint = DateDiff("d", Val(Text1.Text), Val(Text2.Text)) lstAnswer.AddItem "The day difference = " & Mint End Sub
thx for tutorial!
it definitely wont work. try this:
Private Sub cmdCalc_Click()
date1 = txtmonth.text & "/" & txtday.text & "/" & txtyear.text
Mint = DateDiff("d", date1, now) ' now means getting the current date
lstAnswer.AddItem "The day difference = " & Mint
End Sub
im sure this will work if its just the day you want to calculate. in other cases im not sure like calculating the age.
thx
There are currently 1 users browsing this thread. (0 members and 1 guests)