472,334 Members | 1,503 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,334 software developers and data experts.

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 5883
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...
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...
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...
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...
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...
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...
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...
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...
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...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...

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.