then just set a variable for it... eg
and use that variableCode:dim this as long
this = datediff("m", Now, dateToCheck)
msgbox this
Printable View
then just set a variable for it... eg
and use that variableCode:dim this as long
this = datediff("m", Now, dateToCheck)
msgbox this
damn! :mad:
too slow!
I give up, time to go home now anyway :D
hmm it's giving me a really odd number now some thing got messed up i don't know how here is the code as of right now..BTW thx for you help but_why
and the answer is the same everytime
Option Explicit
Dim d1 As Long
Dim m1 As Long
Dim y1 As Long
Private Sub cmdcompute_Click()
picfee.Cls
Dim Name As String
Dim Book As String
Dim CheckMonth As String
Dim CheckDay As String
Dim CheckYear As String
Dim m2 As Long
Dim d2 As Long
Dim y2 As Long
Dim dDate As Date
Dim iDiff As Integer
iDiff = Abs(DateDiff("d", Now, dDate)) * (0.1)
m2 = txtduemonth.Text
d2 = txtdueday.Text
y2 = txtdueyear.Text
dDate = m2 & "-" & d2 & "-" & y2
Name = txtname.Text
Book = txtbook.Text
CheckMonth = txtcheckmonth.Text
CheckDay = txtcheckday.Text
CheckYear = txtcheckyear.Text
picfee.Print Name; " now owes " & iDiff; "for the book" & Book; " that was checked out on" & CheckMonth; " - " & CheckDay; " - " & CheckYear; ""
End Sub
Private Sub Form_Load()
lbldate.Caption = Format(Now, "dddd, mmmm, dd, yyyy")
m1 = Month(Now)
d1 = Day(Now)
y1 = Year(Now)
txttodaymonth.Text = m1
txttodayday.Text = d1
txttodayyear.Text = y1
End Sub
Private Sub Timer1_Timer()
If lbltime.Caption <> CStr(Time) Then
lbltime.Caption = Time
End If
End Sub
VB Code:
iDiff = Abs(DateDiff("d", Now, dDate)) * (0.1) m2 = txtduemonth.Text d2 = txtdueday.Text y2 = txtdueyear.Text dDate = m2 & "-" & d2 & "-" & y2
should be:
VB Code:
m2 = txtduemonth.Text d2 = txtdueday.Text y2 = txtdueyear.Text dDate = m2 & "-" & d2 & "-" & y2 iDiff = Abs(DateDiff("d", Now, dDate)) * (0.1)
You need to get the difference AFTER you set dDate...
that and make sure txtduemonth.Text, txtdueday.Text, and txtdueyear.Text are being set to valid numbers...
And with that i'll bid you farewell. i'll look back at it tomorrow and see how you got on.
ok i got it to work i just need to know how and where do i format the currency the way i have the code now?
Option Explicit
Dim d1 As Long
Dim m1 As Long
Dim y1 As Long
Private Sub cmdcompute_Click()
picfee.Cls
Dim Name As String
Dim Book As String
Dim CheckMonth As String
Dim CheckDay As String
Dim CheckYear As String
Dim m2 As Long
Dim d2 As Long
Dim y2 As Long
Dim dDate As Date
Dim iDiff As Integer
Dim Owe As Currency
m2 = txtduemonth.Text
d2 = txtdueday.Text
y2 = txtdueyear.Text
dDate = m2 & "-" & d2 & "-" & y2
iDiff = Abs(DateDiff("d", Now, dDate))
Owe = iDiff * 0.1
Name = txtname.Text
Book = txtbook.Text
CheckMonth = txtcheckmonth.Text
CheckDay = txtcheckday.Text
CheckYear = txtcheckyear.Text
picfee.Print Name; " now owes " & Owe; " for the book" & Book; " that was checked out on " & CheckMonth; " - " & CheckDay; " - " & CheckYear; ""
End Sub
Private Sub Form_Load()
lbldate.Caption = Format(Now, "dddd, mmmm, dd, yyyy")
m1 = Month(Now)
d1 = Day(Now)
y1 = Year(Now)
txttodaymonth.Text = m1
txttodayday.Text = d1
txttodayyear.Text = y1
End Sub
Private Sub Timer1_Timer()
If lbltime.Caption <> CStr(Time) Then
lbltime.Caption = Time
End If
End Sub
VB Code:
picfee.Print Name & " now owes " & [b]Format(Owe, "currency")[/b] & " for the book" & Book & _ " that was checked out on " & CheckMonth & " - " & CheckDay & " - " & CheckYear
I'm going to bed now. Hope you can get all this working. Best of luck.
ok it all works except that it get's tripped up if there is no input in the due date feild?? what should i do?? what would the if statement for like if no data plz then msgbox plz input a valid date or sdometihng along thoese lines
alright thanks for all your help man you've been a tremendous help thank you soo very much. :cool:
yeah validate the input , like:Quote:
Originally posted by Supreme Cookie
ok it all works except that it get's tripped up if there is no input in the due date feild?? what should i do?? what would the if statement for like if no data plz then msgbox plz input a valid date or sdometihng along thoese lines
if len([textbox].text) = 0 then
'tell user to validate
else
'insert your code here
end if
and aren't long faster since windows is 32bit, it doesnt have to convert the 16->32?
Here you go - it's not finished but it's the right idea.
This code will handle dates (correctly) from 4713BC to 4713AD (and beyond actually - but you have to limit this stuff)
Will convert dates from gregorian to julian to dec's format.
Let me know what you think, eh
You're probably right, but don't longs still take up more memory (even though it isn't significant enough to be worried about)?Quote:
Originally posted by nabeels786
yeah validate the input , like:
if len([textbox].text) = 0 then
'tell user to validate
else
'insert your code here
end if
and aren't long faster since windows is 32bit, it doesnt have to convert the 16->32?
I don't think you understand what he's trying to do...Quote:
Originally posted by yrwyddfa
Here you go - it's not finished but it's the right idea.
This code will handle dates (correctly) from 4713BC to 4713AD (and beyond actually - but you have to limit this stuff)
Will convert dates from gregorian to julian to dec's format.
Let me know what you think, eh
And how we're handling the dates is not incorrectly, so what are you implying?
Sorry - missed the point . . .
longs shouldn't take up more memory as vb aligns data on a 32bit boundary. So if you use 1 bit it will still use 32bits of storage - unless you tell it to do otherwise (like use a UDT or something similar)
(I think!)
Depends how they are used, but the speed difference is basically negligable over integers. Other data types like bytes and singles its quicker, but not too much difference with integers. Well thats just from my own testing. in a 30,000ish loop done 100 times the difference was like in the 1000's of a second. Nothing to be too worried about.Quote:
Originally posted by nabeels786
and aren't long faster since windows is 32bit, it doesnt have to convert the 16->32?
wow you guys are so helpful...i handed in the project i works nicely but i still didn't figure out how to make it so that it doesn't get messed up with a value inputed. I tryed using an If statement to call a msgbox but that messed it up more. Here is the latest code modifications to it. If you figure out the if statements then hook me up.
'Alexander Czank
'Not so copyright but still don't copy it
'or i'll kill you son.
Option Explicit
Dim d1 As Long
Dim m1 As Long
Dim y1 As Long
Private Sub cmdcompute_Click()
picfee.Cls
Dim Name As String
Dim Book As String
Dim CheckMonth As String
Dim CheckDay As String
Dim CheckYear As String
Dim m2 As Integer
Dim d2 As Integer
Dim y2 As Integer
Dim dDate As Date
Dim iDiff As Integer
Dim Owe As Currency
m2 = Val(txtduemonth.Text)
d2 = Val(txtdueday.Text)
y2 = Val(txtdueyear.Text)
dDate = m2 & "-" & d2 & "-" & y2
iDiff = Abs(DateDiff("d", Now, dDate))
Owe = iDiff * 0.1
Name = txtname.Text
Book = txtbook.Text
CheckMonth = txtcheckmonth.Text
CheckDay = txtcheckday.Text
CheckYear = txtcheckyear.Text
picfee.Print Name; " now owes " & Format(Owe, "currency"); " for the book"; Book; ""
picfee.Print "Which was checked out on " & CheckMonth; " - " & CheckDay; " - " & CheckYear; ""
End Sub
Private Sub Form_Load()
lbldate.Caption = Format(Now, "dddd, mmmm, dd, yyyy")
m1 = Month(Now)
d1 = Day(Now)
y1 = Year(Now)
txttodaymonth.Text = m1
txttodayday.Text = d1
txttodayyear.Text = y1
End Sub
Private Sub Quit_Click()
End
End Sub
Private Sub Reset_Click()
picfee.Cls
txtname.Text = ""
txtbook.Text = ""
txtcheckmonth.Text = "mm"
txtcheckday.Text = "dd"
txtcheckyear.Text = "yyyy"
txtduemonth.Text = "mm"
txtdueday.Text = "dd"
txtdueyear.Text = "yyyy"
End Sub
Private Sub Timer1_Timer()
If lbltime.Caption <> CStr(Time) Then
lbltime.Caption = Time
End If
End Sub
:D
VB Code:
m2 = Val(txtduemonth.Text) d2 = Val(txtdueday.Text) y2 = Val(txtdueyear.Text) [b]If m2 = 0 Or d2 = 0 Or y2 = 0 Then MsgBox "Please enter valid data for the date", vbOKOnly, "Error" Exit Sub End If[/b] dDate = m2 & "-" & d2 & "-" & y2
Cool...thanks :cool: :D :) :p ;)
This will validate a date . . .
VB Code:
If lMonth < 1 Or lMonth > 12 Then 'Out of month range fRet = False Else If lDay < 1 Or lDay > DaysInMonth(lMonth, lYear) Then 'Out of day range fRet = False End If End If Public Function DaysInMonth(lMonth As Long, lYear As Long) As Long 'Proposition Place holders . . . Dim a As Boolean, b As Boolean, c As Boolean 'Proposition assignments . . . a = lMonth >= 8 b = lMonth Mod 2 = 0 c = lMonth = 2 'Logic Resolution (see notes above) . . . DaysInMonth = 31 + ((a And Not (b)) Or (Not (a) And b And Not (c))) + _ (3 * c) - (c And IsLeapYear(lYear)) End Function Public Function IsLeapYear(lYear As Long) As Boolean Dim a As Boolean a = lYear Mod 4 = 0 IsLeapYear = (a And lYear Mod 400 = 0) Or (a And lYear Mod 100 <> 0) End Function
Just for a bit of fun . . ..
:D