计数数字循环基于c#中文本框值的设置 [英] count number loop based on set in textbox value in c#

查看:52
本文介绍了计数数字循环基于c#中文本框值的设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好朋友,



我使用此代码来计算数字



  int  Startcount = Convert.ToInt32(TextBox1.Text); 
int Endcount = Convert.ToInt32(TextBox2.Text);
int count = 0 ;
for int i = Startcount; i < 结束; i ++)
{
count = i;
}
label.Text = 数字: + count.ToString( );



textbox1中的值为0,而TextBox2的值为100000000000这个


i am gating error当我的TextBox2.text = 100000000000



i想要根据TextBox1中的设置来计算数字到TextBox2

请给我解决方案我该如何解决从TextBox1借给TextBox2的任何nuber

谢谢

解决方案

你可以在Int32中保存的最大数字是:

  2  147  483  647  

所以你的价值:

< pre lang =c#> 100 000 000 000

太大了!



将您的 Convert.ToInt32 更改为 Convert.ToInt64 调用,并使用长值我nstead of int。


Hello friend,

I am using this code to count number

int Startcount = Convert.ToInt32(TextBox1.Text);
int Endcount = Convert.ToInt32(TextBox2.Text);
int count = 0;
for (int i = Startcount; i < Endcount; i++)
{
    count = i;
}
label.Text = "Number: " + count.ToString();


There is 0 value in textbox1 and TextBox2 value is 100000000000 this

i am gating error when my TextBox2.text = 100000000000

i want to count number based on set in TextBox1 to TextBox2
please give me soluton how can i solve cont any nuber lent from TextBox1 to TextBox2
Thank you

解决方案

The largest number you can hold in an Int32 is:

2,147,483,647

So your value of:

100,000,000,000

is way, way too big!

Change your Convert.ToInt32 to Convert.ToInt64 calls instead, and use long values instead of int.


这篇关于计数数字循环基于c#中文本框值的设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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