|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Function question
Write a function called getFed which returns the average amount of fed used per day over a requested minimum time frame for a particular location. The time frame is the period between the latest two drop events that have recorded a true DropFull.
Pass two arguments (Id and TimeFram) to the function. If no valid time frame exists, return a 0. TimeFrame is expressed in days or fractions of a day. anybody?? |
|
#2
|
||||
|
||||
|
Before you get smashed by the moderators.. let me make a suggestion. Try posting the code you are working on and asking for suggestions on it.. it's not usually a good idea to just ask for code to be written for you.
__________________
Fisherman "Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction." - A.Einstein |
|
#3
|
||||
|
||||
|
Just joking moderators... dont smash me now
![]() |
|
#4
|
|||
|
|||
|
Funny question!FED??Every time??Joking question!?
|
|
#5
|
|||
|
|||
|
okay sorry about that guys..here is what i have so far but the total just doesn't calculate...anyways anybody see an error..and i dont know if this is possible but i need an answer within the hour...hope somebody can help me
Code:
Private Function GetFeedDisappearance(x As Integer, Y As Integer) As Integer
GetFeedDisappearance = x / Y
'Takes x (total feed used) and devides it by X(total days)
End Function
Private Function isDateBetween(tmpDate As String, DateStart As String, DateEnd As String, Optional Exclusive As Boolean = True) As Boolean
If (txtstart = "mm/dd/yy") Or (txtend = "mm/dd/yy") Then
MsgBox "Erorr, Invalid date Format"
Else
Dim tmpVal As Integer
If Exclusive Then tmpVal = 1
If Not Exclusive Then tmpVal = 0
isDateBetween = True
Debug.Print "DateStart - tmpDate = " & DateDiff("d", DateStart, tmpDate)
If DateDiff("d", DateStart, tmpDate) < tmpVal Then
isDateBetween = False
ElseIf DateDiff("d", tmpDate, DateEnd) < tmpVal Then
isDateBetween = False
End If
End If
End Function
Private Sub cmdCheck_Click()
total = 0
If (cmbID = "") Or (txtstart = "mm/dd/yy") Or (txtend = "mm/dd/yy") Then
MsgBox "Error, Invalid input."
Else
If (cmbID = txtID) And (txtDropID = 1) Then
Dim x As String
x = Trim(cmbID.List(cmbID.ListIndex))
cnMain.Recordset.Filter = "DropID= '" & x & " '"
If isDateBetween(txttemp, txtstart, txtend) And (txtfull = 1) Then
total = total + txtTotalByWeight
Else
With cnMain.Recordset
.MoveNext
End With
End If
End If
End If
txtAverage = total
End Sub
Last edited by Onslaught : October 10th, 2003 at 08:46 AM. |
|
#6
|
|||
|
|||
|
What's txtTotalByWeight??txtAverage??U don't declare these variables...
|
|
#7
|
||||
|
||||
|
well... I don't know if this has anything to do with it, but you have an open if statement in isbetweendate
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > Function question |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|