Advice Needed With Function

q582gmzhi

Registered User.
Local time
Today, 01:36
Joined
Dec 23, 2002
Messages
48
Hi,

I use the following code on about 15 buttons on one form.

I think I can put it into one function and pass the Scorepoint which is the variable to it, then call the code to run.

Can someone advise the best way to do it, please.

Dim ScorePoint as integar
Scorepoint = 1 (This changes for each button between 1 and 6)

If Me.tRunsRequired.Value = 0 Then
End
Else
Me.tRunsRequired.Value = Me.tRunsRequired.Value - ScorePoint
End If


Thanks

Daz...
 
On the Click Event for each of the buttons

=fRunsNeeded(n) ' where n is the number of the button, runs got.

In your module:

Function fRunsNeeded(ScorePoint as integer)

Me.tRunsRequired = Me.tRunsRequired - ScorePoint
If Me.tRunsRequired < 0 then Me.tRunsRequired = 0

End Function

.....
Hope it helps
 
Code:
Private Function fRunsRequired(ByVal intScorePoint As Integer) As Integer
    If Not Me.tRunsRequired Then fRunsRequired = Me.tRunsRequired - intScorePoint
End Function

Then, just call and pass the scorepoint value

i.e.

fRunsRequired(1)
 
Do you understand how it works?
 
Yes,

I have seen this type of function before but never used it myself until now.

I have already created another one in the db for another calculation that is used quite a bit.

Thanks

Daz...
 

Users who are viewing this thread

Back
Top Bottom