469,323 Members | 1,575 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,323 developers. It's quick & easy.

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 5362
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by E G | last post: by
8 posts views Thread by Dmitry Klymenko | last post: by
2 posts views Thread by Bob Day | last post: by
11 posts views Thread by Fie Pye | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Gurmeet2796 | last post: by
reply views Thread by mdpf | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.