在vb.net中找到avarege [英] find avarege in vb.net

查看:128
本文介绍了在vb.net中找到avarege的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将文本框值转换为整数.当我在文本框中输入值时,我需要获取平均值.我的代码是这样的
将nn变暗为double
nn = textbox1.text
将kk暗淡为double
kk = textbox2.文字
textb
kk = nn \ 4
然后我得到了错误的味精.它的`不能将字符串转换为double类型的值.
然后我尝试那样
将ll变暗为double
ll = textbox1.text
textbox2.text = ll \ 4
它的工作.
但是显示结果不是两倍
当我输入5到textbox1,然后单击按钮.结果是1.不是1.25
它不可能达到平均水平
请更正密码或为我提供帮助.
我正在使用vb.net
谢谢

how convert textbox value to integer. i need get avarage when i enter value into text box.my code like this
dim nn as double
nn=textbox1.text
dim kk as double
kk=textbox2. text
textb
kk=nn\4
then i got erro msg. its `canont convert string to type double is not valied.
then i try like that
dim ll as double
ll= textbox1.text
textbox2.text= ll\ 4
its work.
but display result is not as a double
when i enter 5 to textbox1 and then click button. result is 1. not 1.25
its not possiible to average
please correct ma code or help me .
im using vb.net
thanks

推荐答案

您使用了错误的运算符.

\运算符返回除法的整数商.例如,表达式14 \ 4的值为3.
/运算符(Visual Basic)将完整的商(包括余数)返回为浮点数.例如,表达式14/4的计算结果为3.5.

参考: http://msdn.microsoft.com/en-us/library /se0w9esz(v=vs.80).aspx [ ^ ]
You are using wrong operator.

The \ Operator returns the integer quotient of a division. For example, the expression 14 \ 4 evaluates to 3.
The / Operator (Visual Basic) returns the full quotient, including the remainder, as a floating-point number. For example, the expression 14 / 4 evaluates to 3.5.

Ref:http://msdn.microsoft.com/en-us/library/se0w9esz(v=vs.80).aspx[^]


尝试kk=CDbl(nn)/4 .
您不应该得到该错误.

对于其他计算也要执行相同的操作.
Try kk=CDbl(nn)/4 .
You should not get the error.

Do the same thing for other calculations as well.


这篇关于在vb.net中找到avarege的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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