Homework Help Excel VBA +K for help

I am having trouble with storing and creating records. Here is the problem. Thanks for any help.

Code a Function that calculates the Area of a Circle (5 points)

ii. Code a Function that Calculates the Perimeter of a Circle (5 points)

iii. Code a Procedure that uses the two above functions to calculate and store: Radii, Areas, and Perimeters of All Circles of R=0 to 1,000 units in a Record (10 points)

iv. The Procedure should also Calculate the Averages of the 1,001 Radii, Areas, and Perimeters, and Compare them to the Radius, Area and Perimeter of the Middle Circle (a circle of 500 units radius). Are they Equal? (10 points)

This is what I have so far but i cant get it to work:

Option Explicit

Type Circles

r As Double

a As Single

p As Single

End Type

Sub problem1()

'code a function that calculates the area of a circle

'a=area

'r=radius

r = InputBox("the radius is ")

For r = 0 To 1000

a = 3.14 * r ^ 2

'display area

MsgBox "The Area is " & a

'code a function that calculates the perimeter

'p=perimeter

p = 2 * r * 3.14

Next r

Dim Circles(1001) As problem1

Circles(1).r = 0

Circles(1).p = 0

Circles(1).a = 0

MsgBox "the area is " & Circles(1).a & "The Perimeter is " & Circles(1).p

End Sub

Thanks and +k for any help.
 
I don't remember much from my VBA coursework, but have you tried reaching out to some of the vba forums or checked online for solutions? After reading that you're getting stuck with defining the variable I would imagine its a fairly simple fix- its been too long since I've done anything in VBA though, sorry.
 
yeah ive checked the forums out there. the defined variable isnt my problem. Its more with how to use the data record and being able to store the data for 1000 different radii.
 
Back
Top