TextBox1.Enabled = false;
finalpricebox.Items.Clear();
namebox.Items.Clear();
int current = 0;
pricebox.Items.Clear();
if (CheckBox1.Checked == true)
{
request.Navigate("http:----------" + TextBox1.Text);
}
else if (CheckBox1.Checked == false)
{
request.Navigate("http://----" + TextBox1.Text);
}
namebox.Focus();
while (!(request.ReadyState == WebBrowserReadyState.Complete))
{
Application.DoEvents();
}
WebClient tClient = new WebClient();
int resultnr = request.Document.GetElementById("searchResults_total").OuterText;
if (resultnr > 30)
{
resultnr = 30;
}
它表示不能将字符串转换为int。在线
int resultnr = request.Document.GetElementById(" searchResults_total")。OuterText; if(resultnr> 30)
为什么我会收到此错误,我真的希望有人可以帮助我
答案 0 :(得分:0)
int resultnr = Convert.ToInt32(request.Document.GetElementById("searchResults_total").OuterText);
答案 1 :(得分:0)
建议使用Int32.TryParse作为安全方
int resultnr =0;
if(int.TryParse(request.Document.GetElementById("searchResults_total").OuterText,out resultnr )
{
if (resultnr > 30)
{
resultnr = 30;
}
}