Computing.Net > Forums > Programming > microsoft visual basic 2008 express

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

microsoft visual basic 2008 express

Reply to Message Icon

Name: frazledvbgal
Date: July 12, 2009 at 13:55:19 Pacific
OS: Windows Vista
Subcategory: General
Comment:

I am trying to teach myself VB 2008. I am trying to get a function statement to work. I am not sure what I am doing wrong.
Here is my code.
Private Function SingleRoll(ByVal area As Integer, _
ByVal coverage As Integer) As Integer

' calculate the number of rolls
Return SingleRoll = area / coverage

End Function

Private Sub btnCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

Dim length As Integer
Dim width As Integer
Dim height As Integer
Dim perimeter As Integer
Dim area As Integer
Dim rolls As Integer
Dim intAnswer As Integer

' calculate the perimeter
perimeter = 2 * length + 2 * Width

' calculate the area
area = perimeter * Height

' use function to calculate the sum or product
Return SingleRoll(area, coverage)

End Sub



Sponsored Link
Ads by Google

Response Number 1
Name: StuartS
Date: July 12, 2009 at 15:40:01 Pacific
Reply:

I dont know what you are trying to do but there a few obviouse errors.

You have Return SingleRoll = area / coverage in the singleRoll function which is fine.

You also have Return SingleRoll(area, coverage) in the btnCalc_Click function which is not correct notwhichstanding that you cannot return the product of a function from outside the function.

You are also attempting to return a value from a subroutine which is not allowed.

If you are attempting to call the SingleRoll function from the btnCalc_Click subroutine cut out the return.

Nowhere in the btnCalc_click function are the variables given values before you start doing calculations on them.

perimeter = 2 * length + 2 * Width is meaningless becasue they will always be zero as will height.

Stuart


0

Response Number 2
Name: frazledvbgal
Date: July 12, 2009 at 16:27:59 Pacific
Reply:

Thank you for your help. I thought that I had defined them to get the value in the length field. ect. This is what I am trying to do.

L=20 20 * 2 = 40
W= 50 50 * 2 = 100
40+100 = 140

H= 12 * 140 = 1680

C= 200
1680/200
My single roll should be 8.4

Rolls = 8.4"


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


MySQL commands with batch... any ideas



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: microsoft visual basic 2008 express

Visual Basic Strip menus www.computing.net/answers/programming/visual-basic-strip-menus/19756.html

Visual basics www.computing.net/answers/programming/visual-basics/17249.html

Visual Basic 2005 Express Edition www.computing.net/answers/programming/visual-basic-2005-express-edition-/10970.html