i'll take em out
Printable View
i'll take em out
this works??Code:Dim x1 As Long, x2 As Long, x3 As Long
Dim x4 As Date
x1 = 2
x2 = 4
x3 = 2002
x4 = Format(x1 & "-" & x2 & "-" & x3, "dd-mmm-yyyy")
MsgBox x4
Yeah, true Hobo... once again too slow.... need faster internet connection ;)
But that won't be causing the error
yea i get the same error i'll just take the stupid hyphens out
what are your d2,m2,y2 values being set to?
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
txtduemonth.Text = m2
txtdueday.Text = d2
txtdueyear.Text = y2
dDate = Format(m2 & d2 & y2, "mm-dd-yyyy")
MsgBox DateDiff("d", Now, dDate)
so they are all 0?
I think your problem is here:
VB Code:
txtduemonth.Text = m2 txtdueday.Text = d2 txtdueyear.Text = y2
Should be:
VB Code:
m2 = txtduemonth.Text d2 = xtdueday.Text y2 = txtdueyear.Text
no the msgbox just gives me the time now lolQuote:
Originally posted by But_Why
this works??Code:Dim x1 As Long, x2 As Long, x3 As Long
Dim x4 As Date
x1 = 2
x2 = 4
x3 = 2002
x4 = Format(x1 & "-" & x2 & "-" & x3, "dd-mmm-yyyy")
MsgBox x4
Yeah, true Hobo... once again too slow.... need faster internet connection ;)
But that won't be causing the error
You've gone the wrong way with Hobos idea. you'll need to get rid of the Format function altogether and just add your thing to the date...
eg
aDate = aLong1 & "-" & aLong2 & "-" & aLong3
Change your code to this:
VB Code:
m2 = txtduemonth.Text d2 = xtdueday.Text y2 = txtdueyear.Text dDate = m2 & "/" & d2 & "/" & y2 MsgBox DateDiff("d", Now, dDate)
sorry, should be:
dDate = m2 & "-" & d2 & "-" & y2
to follow your format.
The time?? :D:D:DQuote:
Originally posted by Supreme Cookie
no the msgbox just gives me the time now lol
:confused:
wierd...
I think The Hobo has the right idea.
ok let me try that because what you sed gives me the same result everytime
yes woo hoo it works you guys rule but now i have another question
lol
You might want to do: abs(MsgBox DateDiff("d", Now, dDate)) incase the value given is negative.
although he might need to know if it is negative... ??
just a thought.
whats your other question?
or are you going to post a new topic with it?
OK now that that worked i don't want it in a msgbox i need it to be inputed in an equation can i just declare a variable for the result it gives me?
Yeah. You might want to do:
VB Code:
Dim iDiff As Integer iDiff = DateDiff("d", Now, dDate) If iDiff < 0 Then 'Book is overdue ElseIf iDiff = 0 Then 'Book is due today Else 'Book isn't due yet End If
b/c the project is supposed to tell you how much you owe the "library" for the overdue book.
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