我正在创建一个网页重新加载器,我正在尝试使用来自用户的输入来获取重新加载的数量,但我无法从用户那里获得输入的数量。
我正在尝试获取用户输入textBox2.Text
,但出现此错误:
input string was not in a currect format
这个错误在这一行kkk = System.Int32.Parse(textBox2.Text);
请帮助我如何正确获取用户输入的int
值。
这是我的程序代码:
public partial class Form1 : Form
{
public int kkk;
public Form1()
{
InitializeComponent();
}
private void progressBar1_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
if (progressBar1.Value != kkk)
{
do
{
try
{
webBrowser1.Navigate(textBox1.Text);
while (webBrowser1.ReadyState != WebBrowserReadyState.Complete)
{
Application.DoEvents();
if(webBrowser1.ReadyState == WebBrowserReadyState.Complete)
{
progressBar1.Value = progressBar1.Value + 1;
}
}
MessageBox.Show("Loaded");
}
catch(Exception)
{
MessageBox.Show("failed");
}
}
while(progressBar1.Value !=kkk);
}
}
private void Form1_Load(object sender, EventArgs e)
{
kkk = System.Int32.Parse(textBox2.Text);
progressBar1.Maximum = kkk;
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}