I want to calculate the surface area of a sphere from an inputed radius
with option strict on. I guess I am not converting something
correctly.
Here is what I am doing:
I have a textbox txtradius that I enter a radius into.
I then have a lable that I want the surface area to be displayed in
called lblsurface
here is my logic.
lblsurface.text = (4 * 3.14 * txtradius * txtradius)
I am getting a conversion error.
I dim txtradius as double
dim lblsurface as double
Thanks for any help 10 1997
"Ron" <pt*****@yahoo. comwrote in news:1169051101 .266111.300510@
51g2000cwl.goog legroups.com:
>
I then have a lable that I want the surface area to be displayed in
called lblsurface
here is my logic.
lblsurface.text = (4 * 3.14 * txtradius * txtradius)
I am getting a conversion error.
I dim txtradius as double
dim lblsurface as double
txtRadius is a textbox right?
In that case you should be doing:
Dim _Radius as Double = Ctype(txtRadiu. text, Double)
Ron wrote:
I want to calculate the surface area of a sphere from an inputed radius
with option strict on. I guess I am not converting something
correctly.
lblsurface.text = (4 * 3.14 * txtradius * txtradius)
You could boil all this down into a single statement, but here's the
long-hand way, so you can see all the conversions going on ...
Dim nRadius as Double = CDbl( txtRadius.Text )
Dim nArea as Double _
= 4 * Math.PI * Math.Pow( nRadius, 2 )
lblSurface.Text = nArea.ToString( "0.000" )
HTH,
Phill W.
here is what I have and it does not work.
Dim _Radius As Double = CType(txtRadius .Text, Double)
CDbl(lblsurface .Text, double) = 4 * 3.14 *
(CDbl(txtRadius .Text) * (CDbl(txtRadius .Text)))
lblVolume.Text = (4 / 3 * 3.14 * (CDbl(txtRadius .Text) *
(CDbl(txtRadius .Text) * (CDbl(txtRadius .Text)))))
still not working.
Phill W. wrote:
Ron wrote:
I want to calculate the surface area of a sphere from an inputed radius
with option strict on. I guess I am not converting something
correctly.
lblsurface.text = (4 * 3.14 * txtradius * txtradius)
You could boil all this down into a single statement, but here's the
long-hand way, so you can see all the conversions going on ...
Dim nRadius as Double = CDbl( txtRadius.Text )
Dim nArea as Double _
= 4 * Math.PI * Math.Pow( nRadius, 2 )
lblSurface.Text = nArea.ToString( "0.000" )
HTH,
Phill W.
In the second line you put
CDbl(lblsurface .Text, double)
it should be
CDbl(lblsurface .Text)
or
CType(lblsurfac e.Text, double)
"Ron" <pt*****@yahoo. comwrote in message
news:11******** *************@1 1g2000cwr.googl egroups.com...
here is what I have and it does not work.
Dim _Radius As Double = CType(txtRadius .Text, Double)
CDbl(lblsurface .Text, double) = 4 * 3.14 *
(CDbl(txtRadius .Text) * (CDbl(txtRadius .Text)))
lblVolume.Text = (4 / 3 * 3.14 * (CDbl(txtRadius .Text) *
(CDbl(txtRadius .Text) * (CDbl(txtRadius .Text)))))
still not working.
Phill W. wrote:
>Ron wrote:
I want to calculate the surface area of a sphere from an inputed radius
with option strict on. I guess I am not converting something
correctly.
lblsurface.text = (4 * 3.14 * txtradius * txtradius)
You could boil all this down into a single statement, but here's the long-hand way, so you can see all the conversions going on ...
Dim nRadius as Double = CDbl( txtRadius.Text ) Dim nArea as Double _ = 4 * Math.PI * Math.Pow( nRadius, 2 )
lblSurface.Tex t = nArea.ToString( "0.000" )
HTH, Phill W.
First, I would use doubles, I would use decimals.
dim decSurface as decimal =0d
dim decRadius as decimal =0d
const decPi as decimal = 3.14d
dim decResult as decimal =0
if decimal.trypars e(lblsurface.te xt,decSurface) then
else
endif
and so on
decResult = (decRadius ^3) * decSurface * 4/3
"BillE" <be****@datamti .comwrote in message
news:%2******** ********@TK2MSF TNGP06.phx.gbl. ..
In the second line you put
CDbl(lblsurface .Text, double)
it should be
CDbl(lblsurface .Text)
or
CType(lblsurfac e.Text, double)
"Ron" <pt*****@yahoo. comwrote in message
news:11******** *************@1 1g2000cwr.googl egroups.com...
>here is what I have and it does not work.
Dim _Radius As Double = CType(txtRadius .Text, Double) CDbl(lblsurface .Text, double) = 4 * 3.14 * (CDbl(txtRadiu s.Text) * (CDbl(txtRadius .Text))) lblVolume.Text = (4 / 3 * 3.14 * (CDbl(txtRadius .Text) * (CDbl(txtRadiu s.Text) * (CDbl(txtRadius .Text)))))
still not working.
Phill W. wrote:
>>Ron wrote: I want to calculate the surface area of a sphere from an inputed radius with option strict on. I guess I am not converting something correctly.
lblsurface.tex t = (4 * 3.14 * txtradius * txtradius)
You could boil all this down into a single statement, but here's the long-hand way, so you can see all the conversions going on ...
Dim nRadius as Double = CDbl( txtRadius.Text ) Dim nArea as Double _ = 4 * Math.PI * Math.Pow( nRadius, 2 )
lblSurface.Te xt = nArea.ToString( "0.000" )
HTH, Phill W.
AMDRIT wrote:
First, I would use doubles, I would use decimals.
.. . .
const decPi as decimal = 3.14d
Why use Decimals when all the Math methods return Doubles?
Why avoid using the Math library? The last time I looked, PI <3.14!
Regards,
Phill W.
Because
Dim dNumber1 As Decimal = Math.PI
Dim dNumber2 As Decimal = Math.PI ^ 2
Dim dNumber3 As Decimal = dNumber2 - dNumber1 + 5&
lblsurface.Text = dNumber3
is not the same as
Dim dNumber1 As Double = Math.PI
Dim dNumber2 As Double = Math.PI ^ 2
Dim dNumber3 As Double = dNumber2 - dNumber1
lblsurface.Text = dNumber3
and if you plan on reusing any of the numbers where they mean anything, then
I recommend decimals.
"Phill W." <p-.-a-.-w-a-r-d@o-p-e-n-.-a-c-.-u-kwrote in message
news:eo******** **@south.jnrs.j a.net...
AMDRIT wrote:
>First, I would use doubles, I would use decimals.
. . .
>const decPi as decimal = 3.14d
Why use Decimals when all the Math methods return Doubles?
Why avoid using the Math library? The last time I looked, PI <3.14!
Regards,
Phill W.
My apologies, that second dNumber3 should have read Dim dNumber3 As Double =
dNumber2 - dNumber1 + 5&
"AMDRIT" <am****@hotmail .comwrote in message
news:Oq******** ******@TK2MSFTN GP06.phx.gbl...
>
Because
Dim dNumber1 As Decimal = Math.PI
Dim dNumber2 As Decimal = Math.PI ^ 2
Dim dNumber3 As Decimal = dNumber2 - dNumber1 + 5&
lblsurface.Text = dNumber3
is not the same as
Dim dNumber1 As Double = Math.PI
Dim dNumber2 As Double = Math.PI ^ 2
Dim dNumber3 As Double = dNumber2 - dNumber1
lblsurface.Text = dNumber3
and if you plan on reusing any of the numbers where they mean anything,
then I recommend decimals.
"Phill W." <p-.-a-.-w-a-r-d@o-p-e-n-.-a-c-.-u-kwrote in message
news:eo******** **@south.jnrs.j a.net...
>AMDRIT wrote:
>>First, I would use doubles, I would use decimals.
. . .
>>const decPi as decimal = 3.14d
Why use Decimals when all the Math methods return Doubles? Why avoid using the Math library? The last time I looked, PI <3.14!
Regards, Phill W.
AMDRIT wrote:
Because
Dim dNumber1 As Decimal = Math.PI
Dim dNumber2 As Decimal = Math.PI ^ 2
Dim dNumber3 As Decimal = dNumber2 - dNumber1 + 5&
lblsurface.Text = dNumber3
is not the same as
Dim dNumber1 As Double = Math.PI
Dim dNumber2 As Double = Math.PI ^ 2
Dim dNumber3 As Double = dNumber2 - dNumber1
lblsurface.Text = dNumber3
and if you plan on reusing any of the numbers where they mean anything, then
I recommend decimals.
Strange, then, that Our Friends in Redmond seem satified with mere
Doubles for the Math methods... :-)
Regards,
Phill W. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Roy Riddex |
last post by:
2nd post of the day! I'm just learning about Arrays at College and have met
a problem. I have 5 text boxes for number input, a command button to add the
numbers to the array, and a command button which displays the array contents
in 5 labels. My program works fine. The problem is that I use a simple If
statement to check for any empty boxes. I've to cut the IF statement and use
a For Each...Next statement to check for empty text boxes but...
|
by: Michael Levin |
last post by:
I've got the following problem. I'm a biologist and I have a device at work
which monitors my frog habitat. The device has a bunch of sensors, and runs
an embedded html server with some java functions defined which know how to
read the hardware sensorts. I access it from wherever I am via any browser,
and it displays the measurements (a set of simple numbers) as Java applets
in a simple html page. One entry in this page (a table cell) looks...
|
by: sam |
last post by:
hi, i am new to C/C++ and have just finished a program based on the UK
national lottery, where you enter 6 numbers, six are generated by the
computer and there are appropriate messages and a compare function to decide
your winnings. I am using Microsoft's C++ version 6 standard, the program
is as follows:
/* * * * * * * * * * * * * * * * * * * *
* *
* Lottery Simulation By Sam...
|
by: munif |
last post by:
i wnat write a C++ program that would read from a CD and display
information about files and folders in the given CD
In simple words you would be performing a simple (ls -l) or (DIR
/S) on the CD.
LOOk at this code
/*
|
by: markus_fried |
last post by:
Hi,
we're using Access97 as frontend to a Oracle db. In Access we have a
bound form which is using a Dynaset as source, global locking and form
locking is off.
All worked well until yesterday. We dublicated some records for a new
session in the Oracle db and since then some of these records cannot
be edited from Access. An error occurs: "This record has been changed
by another user since you started editing...". We are in a single-user
| |
by: Bob Cummings |
last post by:
Not sure if this is the correct place or not. Anyhow in school we were
taught that when trying to calculate the efficiency of an algorithm to
focus on something called FLOPs or Floating Point operations and
disregard all integer operations.
My question is this. I am writing a simulation for animal dispersement
through large landscapes. We are loading data from several different
files to simulate the environment the animals will be...
|
by: MabZiCLe |
last post by:
Hey guys, can you help me with this? C programming major in Turbo c. LOL
Well, this is my problem.
Create a program that accepts 10 positive integers. The program will group and sort all even and odd numbers. Even numbers will be sorted in ascending while odd numbers will be sorted in descending order. If theres is no even numbers found the program will print "NO even numbers" yet it prints the odd numbers, and sort it vice versa.
Use...
|
by: astrogirl77 |
last post by:
Hi,
I'm new to Python and am hoping to find help with coding a Python script, applet.
I code in an old version of Visual Basic 4.0, I have a simple app that is about 3 and a half pages of code long
it does some relatively simple math additions and subtractions
The problem I have is that some numbers get to be very large integers and VB automatically converts this to scientifc notation, what I need is to have all numbers added and...
|
by: astrogirl77 |
last post by:
I'm new to C++ and am hoping to find help with coding a simple C program, am wanting to obtain code and functioning exe's.
I code in an old version of Visual Basic 4.0, I have a simple app that is about 3 and a half pages of code long it does some relatively simple math additions and subtractions
The problem I have is that some numbers get to be very large integers and VB automatically converts this to scientifc notation, what I need is...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |