Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old April 27th, 2005, 05:53 PM
Kudo_Shiho Kudo_Shiho is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Location: Hawaii
Posts: 12 Kudo_Shiho User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 h 2 m 52 sec
Reputation Power: 0
Question help on functions

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.

Reply With Quote
  #2  
Old April 28th, 2005, 03:06 AM
Marc Van Beeume Marc Van Beeume is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2005
Posts: 6 Marc Van Beeume User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 6 m 53 sec
Reputation Power: 0
Thumbs up

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
Comments on this post
nofriends agrees!
Kudo_Shiho agrees!

Reply With Quote
  #3  
Old April 29th, 2005, 12:21 AM
Kudo_Shiho Kudo_Shiho is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Location: Hawaii
Posts: 12 Kudo_Shiho User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 h 2 m 52 sec
Reputation Power: 0
Quote:
Originally Posted by Marc Van Beeume
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
 


Thank you very much for your help

Reply With Quote
  #4  
Old April 29th, 2005, 05:59 AM
Phoenix's Avatar
Phoenix Phoenix is offline
Web-Standards Evangelist
ASP Free Intermediate (1500 - 1999 posts)
 
Join Date: Nov 2003
Posts: 1,522 Phoenix User rank is Corporal (100 - 500 Reputation Level)Phoenix User rank is Corporal (100 - 500 Reputation Level)Phoenix User rank is Corporal (100 - 500 Reputation Level)Phoenix User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 23 h 48 m 4 sec
Reputation Power: 8
News to me...

In VB.Net I always use the "Return" keyword.

Reply With Quote
  #5  
Old April 29th, 2005, 07:12 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 22 h 33 m
Reputation Power: 181
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

Reply With Quote
  #6  
Old April 30th, 2005, 07:02 AM
Phoenix's Avatar
Phoenix Phoenix is offline
Web-Standards Evangelist
ASP Free Intermediate (1500 - 1999 posts)
 
Join Date: Nov 2003
Posts: 1,522 Phoenix User rank is Corporal (100 - 500 Reputation Level)Phoenix User rank is Corporal (100 - 500 Reputation Level)Phoenix User rank is Corporal (100 - 500 Reputation Level)Phoenix User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 23 h 48 m 4 sec
Reputation Power: 8
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

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > help on functions


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT