|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi, I'm trying to write a function in my code for VB.net and I have a problem which I hope someone can help me in.
Code:
iTotalDaily = ComputeDailyCost(iDays, iDailyCost)
iTotalMile = ComputeMileCost(iMile, iMileCost)
Private Function ComputeDailyCost(ByVal a As Integer,_
ByVal b As Integer)
Dim iResult As Integer
iResult = a * b
Return iResult
End Function
Private Function ComputeMileCost(ByVal a As Integer,_
ByVal b As Integer)
Dim iResult As Integer
iResult = a * b
Return iResult
End Function
There is a message that says that the ComputeDailyCost and ComputeMileCost for the first part is not declared. I'm not sure how I declare the ComputeDailyCost and ComputeMileCost so I was wondering if anyone can help me. Thank you. |
|
#2
|
|||
|
|||
|
I'm not a dot net but a VB6 programmer. According to what i know the code should be as follows in VB6. The name of the variable that returns the value is the same as the name of the function. No need to declare a supplemental variable.
Code:
itotaldaily = ComputeDailyCost(iDays, iDailyCost) itotalmile = ComputeMileCost(iDays, iDailyCost) Private Function ComputeDailyCost(ByVal a As Integer, ByVal b As Integer) ComputeDailyCost = a * b End Function Private Function ComputeMileCost(ByVal a As Integer, ByVal b As Integer) ComputeMileCost = a * b End Function |
|
#3
|
|||
|
|||
|
Quote:
Thank you very much for your help ![]() |
|
#4
|
||||
|
||||
|
News to me...
In VB.Net I always use the "Return" keyword. |
|
#5
|
|||
|
|||
|
Marc is correct. VB6 <> VB.Net
__________________
====== Doug G ====== I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain |
|
#6
|
||||
|
||||
|
Code:
iTotalDaily = ComputeDailyCost(iDays, iDailyCost)
iTotalMile = ComputeMileCost(iMile, iMileCost)
Private Function ComputeDailyCost(ByVal a As Integer, ByVal b As Integer) As Integer
Return a * b
End Function
Private Function ComputeMileCost(ByVal a As Integer, ByVal b As Integer) As Integer
Return a * b
End Function
Fix'd |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > help on functions |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|