怎么写这个简单的程序?转换为数字??? [英] How to write this simple program? converting to numbers???

查看:62
本文介绍了怎么写这个简单的程序?转换为数字???的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过选项strict on计算一个球体的表面积来自一个输入半径

。我想我没有正确转换




这是我正在做的事情:

我有一个文本框txtradius我输入一个半径。


我有一个标签,我希望表面区域显示在

中,名为lblsurface

这是我的逻辑。


lblsurface.text =(4 * 3.14 * txtradius * txtradius)


我得到了一个转换错误。

我dim txtradius为双倍

dim lblsurface as double


感谢您的帮助

解决方案

" Ron" < pt ***** @ yahoo.comwrote in news:1169051101.266111.300510 @

51g2000cwl.googlegroups.com:


> ;

我有一个标签,我希望表面区域显示在

中称为lblsurface


这是我的逻辑。


lblsurface.text =(4 * 3.14 * txtradius * txtradius)


我收到转换错误。

我dim txtradius为双倍

dim lblsurface为double



txtRadius是一个文本框吗?


在这种情况下你应该这样做:


Dim _Radius为Double = Ctype(txtRadiu.text,Double)


< blockquote> Ron写道:


我想用一个输入严格打开来计算一个球体的表面积来自一个输入半径

。我想我没有正确转换



lblsurface.text =(4 * 3.14 * txtradius * txtradius)



You可以把所有这些都归结为一个单一的声明,但这里是

长途,所以你可以看到所有的转换......


Dim nRadius为Double = CDbl(txtRadius.Text)

Dim nArea为Double _

= 4 * Math.PI * Math.Pow(nRadius,2)


lblSurface.Text = nArea.ToString(" 0.000")

HTH,

Phill W 。


这里是我所拥有的,它不起作用。


Dim _Radius As Double = CType(txtRadius.Text,双)

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))) ))


仍无法正常工作。


Phill W.写道:


Ron写道:


我想计算表面积来自输入半径的球体

,选项严格打开。我想我没有正确转换



lblsurface.text =(4 * 3.14 * txtradius * txtradius)



You可以把所有这些都归结为一个单一的声明,但这里是

长途,所以你可以看到所有的转换......


Dim nRadius为Double = CDbl(txtRadius.Text)

Dim nArea为Double _

= 4 * Math.PI * Math.Pow(nRadius,2)


lblSurface.Text = nArea.ToString(" 0.000")

HTH,

Phill W 。


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

解决方案

"Ron" <pt*****@yahoo.comwrote in news:1169051101.266111.300510@
51g2000cwl.googlegroups.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.


这篇关于怎么写这个简单的程序?转换为数字???的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆