W
weiliu
Unregistered / Unconfirmed
GUEST, unregistred user!
写了一个小程序,在www.ip138.com上提交一个IP地址查询所在地:
这样写就可以:
procedure TForm1.FormActivate(Sender: TObject);
begin
Form1.WebBrowser1.Navigate('http://www.ip138.com/');
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
var
Myinput : Olevariant;
begin
Myinput := WebBrowser1.OleObject.document.all.item('ip',0);
Myinput.value := '202.96.128.143';
Myinput :=WebBrowser1.oleobject.document.forms.item(0,0).submit;
end;
这样写就不行,运行时出现错误:access violation at address 0045912f in module 'project2.exe'. read of address 00000000.
procedure TForm1.FormActivate(Sender: TObject);
begin
Form1.WebBrowser1.Navigate('http://www.ip138.com/');
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
var
Myinput : Olevariant;
begin
Myinput := WebBrowser1.OleObject.document.all.item('ip',0);
Myinput.value := '202.96.128.143';
Myinput := WebBrowser1.oleobject.document.all.item('submit',0);
Myinput.Click;
end;
这样写就可以:
procedure TForm1.FormActivate(Sender: TObject);
begin
Form1.WebBrowser1.Navigate('http://www.ip138.com/');
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
var
Myinput : Olevariant;
begin
Myinput := WebBrowser1.OleObject.document.all.item('ip',0);
Myinput.value := '202.96.128.143';
Myinput :=WebBrowser1.oleobject.document.forms.item(0,0).submit;
end;
这样写就不行,运行时出现错误:access violation at address 0045912f in module 'project2.exe'. read of address 00000000.
procedure TForm1.FormActivate(Sender: TObject);
begin
Form1.WebBrowser1.Navigate('http://www.ip138.com/');
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
var
Myinput : Olevariant;
begin
Myinput := WebBrowser1.OleObject.document.all.item('ip',0);
Myinput.value := '202.96.128.143';
Myinput := WebBrowser1.oleobject.document.all.item('submit',0);
Myinput.Click;
end;