473,473 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
Create 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 6078
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********************@comcast.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******************@TK2MSFTNGP12.phx.gbl...
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********************@comcast.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****************@TK2MSFTNGP10.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**************@TK2MSFTNGP15.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(ByVal sender As System.Object, ByVal e As
System.EventArgs) 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**************@TK2MSFTNGP12.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********************@comcast.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(ByVal sender As System.Object, ByVal e As
System.EventArgs) 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**************@TK2MSFTNGP12.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
Below is where I have the code now, I do a Build with no errors, and then go
to Debug, Start and the program pops up, I key in a radius, then height
number, and click ok, it does nothing. And, maybe due to the mode I am
running the program, the text boxes all have text like radius.Text and such
in them.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim r As Single, h As Single, pi As Single, v As Single, radius As Single,
hght As Single, volume As Single

r = Val(radius)

h = Val(hght)

pi = 22 / 7

v = pi * (r ^ 2) * h

volume = Str$(v)

End Sub

"OHM ( Terry Burns )" <me@mine.com> wrote in message
news:u8****************@tk2msftngp13.phx.gbl...
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********************@comcast.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(ByVal sender As System.Object, ByVal e As
System.EventArgs) 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**************@TK2MSFTNGP12.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 #11
OK, I think we are a little disconnected here Basil.
The missing part of the picture you seem to have is that the controls on the
form have identifier names which you use to access them. For example, if you
dray a textBox control onto the forms design canvass. It would normally
receive a name of TextBox1. This is the instance name for this instance of
the TextBox class.

One of the members is Text, this is the value which is displayed in the
textbox. There is a default value normally the same name as the instance
name ( TextBox1 ) in my example.

In your button code, you have DIM'd some variables like radius etc. But the
dont seem to be connected to the values in the controls on your form. So,
lets assume you have a control for the radius value called radiusTextBox.

In your code you can ither reference this text value directly or assign it
to a local Variable For example.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim r As Single, h As Single, pi As Single, v As Single, radius As Single,
hght As Single, volume As Single

r = Val(radiusTextBox.Text)

What you did was to this I think

r = Val(radius)

This has the affect of returning the name of the control to the 'r' local
variable.

Your button code should look something similar to this.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim vol, len, rad As Double

len = Convert.ToDouble(Me.lengthTextBox.Text)

rad = Convert.ToDouble(Me.radiusTextBox.Text)

vol = len * Math.PI * rad ^ 2

Me.volumeLabel.Text = vol.ToString("0.##")

End Sub
HTH

--
OHM ( Terry Burns )

http://TrainingOn.net

"Basil Fawlty" <Ba***************@NOSPAMyahoo.com> wrote in message
news:Vv********************@comcast.com...
Below is where I have the code now, I do a Build with no errors, and then
go to Debug, Start and the program pops up, I key in a radius, then height
number, and click ok, it does nothing. And, maybe due to the mode I am
running the program, the text boxes all have text like radius.Text and
such in them.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim r As Single, h As Single, pi As Single, v As Single, radius As Single,
hght As Single, volume As Single

r = Val(radius)

h = Val(hght)

pi = 22 / 7

v = pi * (r ^ 2) * h

volume = Str$(v)

End Sub

"OHM ( Terry Burns )" <me@mine.com> wrote in message
news:u8****************@tk2msftngp13.phx.gbl...
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********************@comcast.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(ByVal sender As System.Object, ByVal e As
System.EventArgs) 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**************@TK2MSFTNGP12.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 #12
Sorry

//
r = Val(radius)

This has the affect of returning the name of the control to the 'r' local
variable.
//

Should have read.

This has the affect of returning the name of the local radius variable to
the 'r' local variable, which is confused really.

--
OHM ( Terry Burns )

http://TrainingOn.net

"OHM ( Terry Burns )" <me@mine.com> wrote in message
news:uB**************@tk2msftngp13.phx.gbl...
OK, I think we are a little disconnected here Basil.
The missing part of the picture you seem to have is that the controls on
the form have identifier names which you use to access them. For example,
if you dray a textBox control onto the forms design canvass. It would
normally receive a name of TextBox1. This is the instance name for this
instance of the TextBox class.

One of the members is Text, this is the value which is displayed in the
textbox. There is a default value normally the same name as the instance
name ( TextBox1 ) in my example.

In your button code, you have DIM'd some variables like radius etc. But
the dont seem to be connected to the values in the controls on your form.
So, lets assume you have a control for the radius value called
radiusTextBox.

In your code you can ither reference this text value directly or assign it
to a local Variable For example.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim r As Single, h As Single, pi As Single, v As Single, radius As Single,
hght As Single, volume As Single

r = Val(radiusTextBox.Text)

What you did was to this I think

r = Val(radius)

This has the affect of returning the name of the control to the 'r' local
variable.

Your button code should look something similar to this.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim vol, len, rad As Double

len = Convert.ToDouble(Me.lengthTextBox.Text)

rad = Convert.ToDouble(Me.radiusTextBox.Text)

vol = len * Math.PI * rad ^ 2

Me.volumeLabel.Text = vol.ToString("0.##")

End Sub
HTH

--
OHM ( Terry Burns )

http://TrainingOn.net

"Basil Fawlty" <Ba***************@NOSPAMyahoo.com> wrote in message
news:Vv********************@comcast.com...
Below is where I have the code now, I do a Build with no errors, and then
go to Debug, Start and the program pops up, I key in a radius, then
height number, and click ok, it does nothing. And, maybe due to the mode
I am running the program, the text boxes all have text like radius.Text
and such in them.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim r As Single, h As Single, pi As Single, v As Single, radius As
Single, hght As Single, volume As Single

r = Val(radius)

h = Val(hght)

pi = 22 / 7

v = pi * (r ^ 2) * h

volume = Str$(v)

End Sub

"OHM ( Terry Burns )" <me@mine.com> wrote in message
news:u8****************@tk2msftngp13.phx.gbl...
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********************@comcast.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(ByVal sender As System.Object, ByVal e As
System.EventArgs) 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**************@TK2MSFTNGP12.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 #13
I'm sorry, but your going over my head. What do I change based on the below
being my code at this time below? I'm lost as I do not know where to make
the text box changes to bring about the connection to grab input for the
program to work in properties, on the form screen, hand mod the code, if so
which textbox pre-keyed in do I mod?????? I'm just too new to this.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim r As Single, h As Single, pi As Single, v As Single

r = Val(radius.text)

h = Val(hght.text)

pi = 22 / 7

v = pi * (r ^ 2) * h

volume.text = Str$(v)

End Sub

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles TextBox1.TextChanged

End Sub

Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles TextBox3.TextChanged

End Sub

Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles TextBox2.TextChanged

End Sub

Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Label1.Click

End Sub

Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Label2.Click

End Sub

Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Label3.Click

End Sub

End Class
"OHM ( Terry Burns )" <me@mine.com> wrote in message
news:uB**************@tk2msftngp13.phx.gbl...
OK, I think we are a little disconnected here Basil.
The missing part of the picture you seem to have is that the controls on
the form have identifier names which you use to access them. For example,
if you dray a textBox control onto the forms design canvass. It would
normally receive a name of TextBox1. This is the instance name for this
instance of the TextBox class.

One of the members is Text, this is the value which is displayed in the
textbox. There is a default value normally the same name as the instance
name ( TextBox1 ) in my example.

In your button code, you have DIM'd some variables like radius etc. But
the dont seem to be connected to the values in the controls on your form.
So, lets assume you have a control for the radius value called
radiusTextBox.

In your code you can ither reference this text value directly or assign it
to a local Variable For example.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim r As Single, h As Single, pi As Single, v As Single, radius As Single,
hght As Single, volume As Single

r = Val(radiusTextBox.Text)

What you did was to this I think

r = Val(radius)

This has the affect of returning the name of the control to the 'r' local
variable.

Your button code should look something similar to this.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim vol, len, rad As Double

len = Convert.ToDouble(Me.lengthTextBox.Text)

rad = Convert.ToDouble(Me.radiusTextBox.Text)

vol = len * Math.PI * rad ^ 2

Me.volumeLabel.Text = vol.ToString("0.##")

End Sub
HTH

--
OHM ( Terry Burns )

http://TrainingOn.net

"Basil Fawlty" <Ba***************@NOSPAMyahoo.com> wrote in message
news:Vv********************@comcast.com...
Below is where I have the code now, I do a Build with no errors, and then
go to Debug, Start and the program pops up, I key in a radius, then
height number, and click ok, it does nothing. And, maybe due to the mode
I am running the program, the text boxes all have text like radius.Text
and such in them.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim r As Single, h As Single, pi As Single, v As Single, radius As
Single, hght As Single, volume As Single

r = Val(radius)

h = Val(hght)

pi = 22 / 7

v = pi * (r ^ 2) * h

volume = Str$(v)

End Sub

"OHM ( Terry Burns )" <me@mine.com> wrote in message
news:u8****************@tk2msftngp13.phx.gbl...
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********************@comcast.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(ByVal sender As System.Object, ByVal e As
System.EventArgs) 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**************@TK2MSFTNGP12.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 #14
I got it to run, I was going to the wrong place to mod the text box name in
the properties. What is the best way to run the program, Iaftera good build
I go to Debug and Start, isn't there a better or alternate way? Also, I see
text in the textboxes, why? Will that go away if I run it not in the IDE?

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim r As Single, h As Single, pi As Single, v As Single

r = Val(radius.Text)

h = Val(hght.Text)

pi = 22 / 7

v = pi * (r ^ 2) * h

volume.Text = Str$(v)

End Sub

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles radius.TextChanged

End Sub

Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles volume.TextChanged

End Sub

Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles hght.TextChanged

End Sub

Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Label1.Click

End Sub

Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Label2.Click

End Sub

Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Label3.Click

End Sub

End Class

"Basil Fawlty" <Ba***************@NOSPAMyahoo.com> wrote in message
news:ge********************@comcast.com...
I'm sorry, but your going over my head. What do I change based on the
below being my code at this time below? I'm lost as I do not know where
to make the text box changes to bring about the connection to grab input
for the program to work in properties, on the form screen, hand mod the
code, if so which textbox pre-keyed in do I mod?????? I'm just too new to
this.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim r As Single, h As Single, pi As Single, v As Single

r = Val(radius.text)

h = Val(hght.text)

pi = 22 / 7

v = pi * (r ^ 2) * h

volume.text = Str$(v)

End Sub

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles TextBox1.TextChanged

End Sub

Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles TextBox3.TextChanged

End Sub

Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles TextBox2.TextChanged

End Sub

Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Label1.Click

End Sub

Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Label2.Click

End Sub

Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Label3.Click

End Sub

End Class
"OHM ( Terry Burns )" <me@mine.com> wrote in message
news:uB**************@tk2msftngp13.phx.gbl...
OK, I think we are a little disconnected here Basil.
The missing part of the picture you seem to have is that the controls on
the form have identifier names which you use to access them. For example,
if you dray a textBox control onto the forms design canvass. It would
normally receive a name of TextBox1. This is the instance name for this
instance of the TextBox class.

One of the members is Text, this is the value which is displayed in the
textbox. There is a default value normally the same name as the instance
name ( TextBox1 ) in my example.

In your button code, you have DIM'd some variables like radius etc. But
the dont seem to be connected to the values in the controls on your form.
So, lets assume you have a control for the radius value called
radiusTextBox.

In your code you can ither reference this text value directly or assign
it to a local Variable For example.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim r As Single, h As Single, pi As Single, v As Single, radius As
Single,
hght As Single, volume As Single

r = Val(radiusTextBox.Text)

What you did was to this I think

r = Val(radius)

This has the affect of returning the name of the control to the 'r' local
variable.

Your button code should look something similar to this.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim vol, len, rad As Double

len = Convert.ToDouble(Me.lengthTextBox.Text)

rad = Convert.ToDouble(Me.radiusTextBox.Text)

vol = len * Math.PI * rad ^ 2

Me.volumeLabel.Text = vol.ToString("0.##")

End Sub
HTH

--
OHM ( Terry Burns )

http://TrainingOn.net

"Basil Fawlty" <Ba***************@NOSPAMyahoo.com> wrote in message
news:Vv********************@comcast.com...
Below is where I have the code now, I do a Build with no errors, and
then go to Debug, Start and the program pops up, I key in a radius, then
height number, and click ok, it does nothing. And, maybe due to the
mode I am running the program, the text boxes all have text like
radius.Text and such in them.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim r As Single, h As Single, pi As Single, v As Single, radius As
Single, hght As Single, volume As Single

r = Val(radius)

h = Val(hght)

pi = 22 / 7

v = pi * (r ^ 2) * h

volume = Str$(v)

End Sub

"OHM ( Terry Burns )" <me@mine.com> wrote in message
news:u8****************@tk2msftngp13.phx.gbl...
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********************@comcast.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(ByVal sender As System.Object, ByVal e As
> System.EventArgs) 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**************@TK2MSFTNGP12.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 #15
r = Val(radius.text)

^^^^^^is good as long as your textbox for radius is called 'radius' and you
DONT have a local variable in your button code called the same name

--
OHM ( Terry Burns )

http://TrainingOn.net

"Basil Fawlty" <Ba***************@NOSPAMyahoo.com> wrote in message
news:ge********************@comcast.com...
I'm sorry, but your going over my head. What do I change based on the
below being my code at this time below? I'm lost as I do not know where
to make the text box changes to bring about the connection to grab input
for the program to work in properties, on the form screen, hand mod the
code, if so which textbox pre-keyed in do I mod?????? I'm just too new to
this.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim r As Single, h As Single, pi As Single, v As Single

r = Val(radius.text)

h = Val(hght.text)

pi = 22 / 7

v = pi * (r ^ 2) * h

volume.text = Str$(v)

End Sub

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles TextBox1.TextChanged

End Sub

Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles TextBox3.TextChanged

End Sub

Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles TextBox2.TextChanged

End Sub

Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Label1.Click

End Sub

Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Label2.Click

End Sub

Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Label3.Click

End Sub

End Class
"OHM ( Terry Burns )" <me@mine.com> wrote in message
news:uB**************@tk2msftngp13.phx.gbl...
OK, I think we are a little disconnected here Basil.
The missing part of the picture you seem to have is that the controls on
the form have identifier names which you use to access them. For example,
if you dray a textBox control onto the forms design canvass. It would
normally receive a name of TextBox1. This is the instance name for this
instance of the TextBox class.

One of the members is Text, this is the value which is displayed in the
textbox. There is a default value normally the same name as the instance
name ( TextBox1 ) in my example.

In your button code, you have DIM'd some variables like radius etc. But
the dont seem to be connected to the values in the controls on your form.
So, lets assume you have a control for the radius value called
radiusTextBox.

In your code you can ither reference this text value directly or assign
it to a local Variable For example.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim r As Single, h As Single, pi As Single, v As Single, radius As
Single,
hght As Single, volume As Single

r = Val(radiusTextBox.Text)

What you did was to this I think

r = Val(radius)

This has the affect of returning the name of the control to the 'r' local
variable.

Your button code should look something similar to this.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim vol, len, rad As Double

len = Convert.ToDouble(Me.lengthTextBox.Text)

rad = Convert.ToDouble(Me.radiusTextBox.Text)

vol = len * Math.PI * rad ^ 2

Me.volumeLabel.Text = vol.ToString("0.##")

End Sub
HTH

--
OHM ( Terry Burns )

http://TrainingOn.net

"Basil Fawlty" <Ba***************@NOSPAMyahoo.com> wrote in message
news:Vv********************@comcast.com...
Below is where I have the code now, I do a Build with no errors, and
then go to Debug, Start and the program pops up, I key in a radius, then
height number, and click ok, it does nothing. And, maybe due to the
mode I am running the program, the text boxes all have text like
radius.Text and such in them.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim r As Single, h As Single, pi As Single, v As Single, radius As
Single, hght As Single, volume As Single

r = Val(radius)

h = Val(hght)

pi = 22 / 7

v = pi * (r ^ 2) * h

volume = Str$(v)

End Sub

"OHM ( Terry Burns )" <me@mine.com> wrote in message
news:u8****************@tk2msftngp13.phx.gbl...
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********************@comcast.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(ByVal sender As System.Object, ByVal e As
> System.EventArgs) 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**************@TK2MSFTNGP12.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 #16
The text in the text boxes are default values. If you dont want it clear it
from the properties box.

HTH

--
Terry Burns
http://TrainingOn.net
"Basil Fawlty" <Ba***************@NOSPAMyahoo.com> wrote in message
news:85********************@comcast.com...
I got it to run, I was going to the wrong place to mod the text box name in
the properties. What is the best way to run the program, Iaftera good
build I go to Debug and Start, isn't there a better or alternate way?
Also, I see text in the textboxes, why? Will that go away if I run it not
in the IDE?

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim r As Single, h As Single, pi As Single, v As Single

r = Val(radius.Text)

h = Val(hght.Text)

pi = 22 / 7

v = pi * (r ^ 2) * h

volume.Text = Str$(v)

End Sub

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles radius.TextChanged

End Sub

Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles volume.TextChanged

End Sub

Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles hght.TextChanged

End Sub

Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Label1.Click

End Sub

Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Label2.Click

End Sub

Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Label3.Click

End Sub

End Class

"Basil Fawlty" <Ba***************@NOSPAMyahoo.com> wrote in message
news:ge********************@comcast.com...
I'm sorry, but your going over my head. What do I change based on the
below being my code at this time below? I'm lost as I do not know where
to make the text box changes to bring about the connection to grab input
for the program to work in properties, on the form screen, hand mod the
code, if so which textbox pre-keyed in do I mod?????? I'm just too new
to this.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim r As Single, h As Single, pi As Single, v As Single

r = Val(radius.text)

h = Val(hght.text)

pi = 22 / 7

v = pi * (r ^ 2) * h

volume.text = Str$(v)

End Sub

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TextBox1.TextChanged

End Sub

Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TextBox3.TextChanged

End Sub

Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TextBox2.TextChanged

End Sub

Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Label1.Click

End Sub

Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Label2.Click

End Sub

Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Label3.Click

End Sub

End Class
"OHM ( Terry Burns )" <me@mine.com> wrote in message
news:uB**************@tk2msftngp13.phx.gbl...
OK, I think we are a little disconnected here Basil.
The missing part of the picture you seem to have is that the controls on
the form have identifier names which you use to access them. For
example, if you dray a textBox control onto the forms design canvass. It
would normally receive a name of TextBox1. This is the instance name
for this instance of the TextBox class.

One of the members is Text, this is the value which is displayed in the
textbox. There is a default value normally the same name as the instance
name ( TextBox1 ) in my example.

In your button code, you have DIM'd some variables like radius etc. But
the dont seem to be connected to the values in the controls on your
form. So, lets assume you have a control for the radius value called
radiusTextBox.

In your code you can ither reference this text value directly or assign
it to a local Variable For example.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim r As Single, h As Single, pi As Single, v As Single, radius As
Single,
hght As Single, volume As Single

r = Val(radiusTextBox.Text)

What you did was to this I think

r = Val(radius)

This has the affect of returning the name of the control to the 'r'
local variable.

Your button code should look something similar to this.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim vol, len, rad As Double

len = Convert.ToDouble(Me.lengthTextBox.Text)

rad = Convert.ToDouble(Me.radiusTextBox.Text)

vol = len * Math.PI * rad ^ 2

Me.volumeLabel.Text = vol.ToString("0.##")

End Sub
HTH

--
OHM ( Terry Burns )

http://TrainingOn.net

"Basil Fawlty" <Ba***************@NOSPAMyahoo.com> wrote in message
news:Vv********************@comcast.com...
Below is where I have the code now, I do a Build with no errors, and
then go to Debug, Start and the program pops up, I key in a radius,
then height number, and click ok, it does nothing. And, maybe due to
the mode I am running the program, the text boxes all have text like
radius.Text and such in them.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim r As Single, h As Single, pi As Single, v As Single, radius As
Single, hght As Single, volume As Single

r = Val(radius)

h = Val(hght)

pi = 22 / 7

v = pi * (r ^ 2) * h

volume = Str$(v)

End Sub

"OHM ( Terry Burns )" <me@mine.com> wrote in message
news:u8****************@tk2msftngp13.phx.gbl...
> 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********************@comcast.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(ByVal sender As System.Object, ByVal e As
>> System.EventArgs) 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**************@TK2MSFTNGP12.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 #17

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

Similar topics

3
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...
4
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...
6
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...
3
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...
8
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...
2
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...
11
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...
8
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...
8
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! ...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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,...
1
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.