Creating a volume calculator

I am trying to learn Visual basic and am trying to follow a tutorial to calculate the volume of a cylinder.
 I have followed the tutorial but when I run the program I get an error message
saying no Data or method found . I have the interface and all the boxes and labels are as instructed.
The tutorial is below without the picture of the interface. am I failing to follow it precise or is it  a typo in the tutorial.


Lesson 2.   A program to calculate the Volume of a Cylinder
This program is a simple program that calculates the volume of a cylinder. Let design the interface:


First of all, go to the properties window and change the form caption to Volume of Cylinder, then drag and insert three labels into the form and change their captions to Base Radius, height and volume respectively. After that, insert three Text Boxes and clear its text contents so that you get three empty boxes. Named the text boxes as radius, hght (we cannot use height as it is the built-in control name of VB) and volume respectively. Lastly, insert a command button and change its caption to O.K and its name to OK. Now save the project as cylinder.vbp and the form as cylinder.vbp as well

Now we shall attempt to write the codes for the cylinder program where the interface is shown in Figure 2.8. First of all, name the textbox as radius, hght, and volume. To get the values of the various textboxes, use Val(radius.text), Val(hght.Text) and assign them to the variables r and h. In addition, assign the value 22/7 to the variable pi. After that, write the equation v = pi * (r ^ 2) * h to compute the value of volume of cylinder and then assign it to the variable v. Finally, display the value in the volume textbox using the function Str$.

 Private Sub OK_Click( )

r = Val(radius.Text)

h = Val(hght.Text)

pi = 22 / 7

v = pi * (r ^ 2) * h

volume.Text= Str$(v)

End Sub

 When you run the program, you should be able to see the interface as shown in Figure 2.8.  If you enter a value each in the radius box and the height box, then click OK; the value of the Volume will be displayed in the volume box.
Its when I click OK  is were I get an error, saying no data or method found.

Regards Planner
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


make sure you have named the button OK

and the textboxes


than should it work....
I don't know if you ever plan on using this program for exact calculations, but if you do want to, I recommend another approximation of pi, because 22 / 7 is... well... very rough.
What I'd recommend is:

pi = CDbl(4 * Atn(1))

Which means 4 * arctan(1)
and arctan(1) = pi / 4

Atan Asfaloth

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
you're looking at: probably?
Found other sites to learn vb6:

and look in your local bookstore, you probably can pick up a good book about VB6 for a dollar or so, since it's become quite ancient already :D

If you want to learn something, better learn it the right way at once. It saves you a lot of troubles and gives you a better learning experience and result in the end.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.