473,587 Members | 2,580 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need Help Computing Volume of Cylinder

Hi everyone, I have an assignment, to create a simple VB program that
computes the volume of a cylinder. The Form is pretty simple, it has a
label and text box for base radius, another for height and another for
volume with an OK button. I have the code to put into the OK button (Which
I've done):

Private Sub OK_Click( ) --not this line
r = Val(radius.Text ) --input this line
h = Val(hght.Text) --input this line
pi = 22 / 7 --input this line
v = pi * (r ^ 2) * h --input this line
volume.Text= Str$(v) --input this line
End Sub --not this line
When I go to run the Build, it complains I have not declared the variables
that you see above. Where do I goto do that? I assume under the label or
text box for the base radius, and so forth, but which one? What do I key
into them that is syntactically correct to match the code I was given to
use?

I am using VB.NET 2003 SE. Please let me know if I need to post more code,
and where I would get it from to post.

My many thanks for any assistance.
Nov 21 '05 #1
16 6104
Try something like this ( Untested )

Private Sub OK_Click( ) --not this line
dim r as double = Val(radius.Text ) --input this line
dim h as double= Val(hght.Text) --input this line
dim v as double =MATH.PI * (r ^ 2) * h --input this line
volume.Text= Str$(v) --input this line
End Sub --not this line

--
OHM ( Terry Burns )

http://TrainingOn.net

"Basil Fawlty" <Ba************ ***@NOSPAMyahoo .com> wrote in message
news:lf******** ************@co mcast.com...
Hi everyone, I have an assignment, to create a simple VB program that
computes the volume of a cylinder. The Form is pretty simple, it has a
label and text box for base radius, another for height and another for
volume with an OK button. I have the code to put into the OK button
(Which
I've done):

Private Sub OK_Click( ) --not this line
r = Val(radius.Text ) --input this line
h = Val(hght.Text) --input this line
pi = 22 / 7 --input this line
v = pi * (r ^ 2) * h --input this line
volume.Text= Str$(v) --input this line
End Sub --not this line
When I go to run the Build, it complains I have not declared the variables
that you see above. Where do I goto do that? I assume under the label or
text box for the base radius, and so forth, but which one? What do I key
into them that is syntactically correct to match the code I was given to
use?

I am using VB.NET 2003 SE. Please let me know if I need to post more
code,
and where I would get it from to post.

My many thanks for any assistance.

Nov 21 '05 #2
Ok, I just did that, and when I build, the errors are a lot less which is
great, it now say the radius, hght and volume are not declared. So clearly
they must be, but declared in what way? To hold a empty slot and await for
user input? I don't think this would be a dim. Sorry to be a dense dork,
but I need more help. My many thanks for the help you have already
provided.

"OHM ( Terry Burns )" <me@mine.com> wrote in message
news:%2******** **********@TK2M SFTNGP12.phx.gb l...
Try something like this ( Untested )

Private Sub OK_Click( ) --not this line
dim r as double = Val(radius.Text ) --input this line
dim h as double= Val(hght.Text) --input this line
dim v as double =MATH.PI * (r ^ 2) * h --input this line
volume.Text= Str$(v) --input this line
End Sub --not this line

--
OHM ( Terry Burns )

http://TrainingOn.net

"Basil Fawlty" <Ba************ ***@NOSPAMyahoo .com> wrote in message
news:lf******** ************@co mcast.com...
Hi everyone, I have an assignment, to create a simple VB program that
computes the volume of a cylinder. The Form is pretty simple, it has a
label and text box for base radius, another for height and another for
volume with an OK button. I have the code to put into the OK button
(Which
I've done):

Private Sub OK_Click( ) --not this line
r = Val(radius.Text ) --input this line
h = Val(hght.Text) --input this line
pi = 22 / 7 --input this line
v = pi * (r ^ 2) * h --input this line
volume.Text= Str$(v) --input this line
End Sub --not this line
When I go to run the Build, it complains I have not declared the
variables
that you see above. Where do I goto do that? I assume under the label
or
text box for the base radius, and so forth, but which one? What do I key
into them that is syntactically correct to match the code I was given to
use?

I am using VB.NET 2003 SE. Please let me know if I need to post more
code,
and where I would get it from to post.

My many thanks for any assistance.


Nov 21 '05 #3
Basil,

That is because it is an English Car, the steering wheel is on the other
side you know.

However when you set those textboxes on your form, it will probably go
better.

Cor
Nov 21 '05 #4
Ok, what do you mean by set the textboxes? You know, I only know how to run
a B&B... not this programming stuff

"Cor Ligthert" <no************ @planet.nl> wrote in message
news:uM******** ********@TK2MSF TNGP10.phx.gbl. ..
Basil,

That is because it is an English Car, the steering wheel is on the other
side you know.

However when you set those textboxes on your form, it will probably go
better.

Cor

Nov 21 '05 #5
Basil,
Ok, what do you mean by set the textboxes? You know, I only know how to
run a B&B... not this programming stuff

This is a newsgroup about programming.

Cor
Nov 21 '05 #6
Which is why I'm here instead of giving my car a good thrashing :)

"Cor Ligthert" <no************ @planet.nl> wrote in message
news:OD******** ******@TK2MSFTN GP15.phx.gbl...
Basil,
Ok, what do you mean by set the textboxes? You know, I only know how to
run a B&B... not this programming stuff

This is a newsgroup about programming.

Cor

Nov 21 '05 #7
Basil,

Click right on those textboxes you have draged on your form and gives them
in the properties what you open by clicking on that text, the "name" as
have called them in the code.

Cor
Nov 21 '05 #8
Ok, did that, for the 3 text boxes, not the ok button that doesthe compute,
yet I still get the same build error, which is:
"text is not a member of single, name hght is not declared and name volume
is not declared." Here is the latest code behind the ok button at this
point:

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
Dim r As Single, h As Single, pi As Single, v As Single, radius As Single

r = Val(radius.Text )

h = Val(hght.Text)

pi = 22 / 7

v = pi * (r ^ 2) * h

volume.Text = Str$(v)

End Sub
"Cor Ligthert" <no************ @planet.nl> wrote in message
news:Oo******** ******@TK2MSFTN GP12.phx.gbl...
Basil,

Click right on those textboxes you have draged on your form and gives them
in the properties what you open by clicking on that text, the "name" as
have called them in the code.

Cor

Nov 21 '05 #9
Which means that radius is not a control in this scope and does not have a
Text property.

You defined it as a single in your button code. If you also have a control
called radius, then this is not seen inside the button code scope. This is
called a hole in the scope.
HTH
--
OHM ( Terry Burns )

http://TrainingOn.net

"Basil Fawlty" <Ba************ ***@NOSPAMyahoo .com> wrote in message
news:HP******** ************@co mcast.com...
Ok, did that, for the 3 text boxes, not the ok button that doesthe
compute, yet I still get the same build error, which is:
"text is not a member of single, name hght is not declared and name volume
is not declared." Here is the latest code behind the ok button at this
point:

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
Dim r As Single, h As Single, pi As Single, v As Single, radius As Single

r = Val(radius.Text )

h = Val(hght.Text)

pi = 22 / 7

v = pi * (r ^ 2) * h

volume.Text = Str$(v)

End Sub
"Cor Ligthert" <no************ @planet.nl> wrote in message
news:Oo******** ******@TK2MSFTN GP12.phx.gbl...
Basil,

Click right on those textboxes you have draged on your form and gives
them in the properties what you open by clicking on that text, the
"name" as have called them in the code.

Cor


Nov 21 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
19107
by: dreamer | last post by:
I am making a program for a friend with a disability. I need to adjust his audio volume using the keyboard as he cannot use a mouse. Any suggestions as to how I can raise the volume using the up arrow on the keyboard and decrease the volume using the down arrow? I am using VB 5. Many thanks in advance.
4
1701
by: YeeCN | last post by:
Hi, I need to write an application that requires HUGH volume of number crunching (tens of billions of calculations). Speed is the single most important factor for me. I am wondering is .NET (vb, c#) the right framework to develop the application so whether I should look somewhere else. Any help or suggestions is greatly appreciated.
6
2130
by: E G | last post by:
Hi! I am having problems in designing a class. First, I have a base class that allocates a 3D data set and allows some other mathematical operations with it, something like this: template <typename T> class BasicArray {
3
20181
by: rafa | last post by:
Hi I'm just learning C and I was trying to do an exercise in a book which asks me to write a program to calculate the volume of a sphere. I know the formula is Volume = (4/3)*(Pi)*(Radius)^3 and I've been trying to write that but have been unsuccesfull so far. I tryed: volume = 4/3 * PI * radius; volume = volume * volume * volume; or
8
3254
by: Dmitry Klymenko | last post by:
Do exists a way to detect a volume label of a disk? I've found the way to do this using WMI (System.Management) or winapi function. The second solution is principal non-portable in future, the first one require service WMI to work on client (for sure it's not a guarantee to be allways running). I do not want to include in my application logic,...
2
14429
by: Bob Day | last post by:
Using VS 2003, VB. Net, MSDE... Usining task sheduler, I wish to mute the volume in the .bat file that task scheduler runs (windows XP Pro). I don't see anyway to do this via a .bat line command (if there is, please let me know). So the next option would be to write a small .net program that would do it and run that via task scheduler. ...
11
3626
by: Fie Pye | last post by:
Hallo I would like to have a high class open source tools for scientific computing and powerful 2D and 3D data visualisation. Therefore I chosepython, numpy and scipy as a base. Now I am in search for a visualisation tool. I tried matplotlib and py_opendx with OpenDx. OpenDx seems to me very good but the project py_opendx looks like closed....
8
1734
by: Lykins | last post by:
We currently use Access 2003 in our company and have had this issues from every version from Access 97 to 2003. We deal with large databases and run a lot of queries over tables with millions of records in them. The problem comes in that when we pull a dataset out of a large table we do not get the same result every time. Example is...
8
1745
by: ash8ley9 | last post by:
Hello. I have started working on the assignment below but I don't know much about it. I am stuck. I will paste what I have done so far under this assignment. Any help is much appreciated! Thanks! __________________________________________________________________ BCP 1 Special Geometry Calculator Write a program that calculates the...
0
8206
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8340
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8220
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6621
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5713
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3875
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2353
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1452
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1185
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.