Delphi/IEをオートフィルしよう


サンプルコード
function SetIE_AutoFill(vDoccument:Variant;
         ValueLists : TStrings ; vMode : integer
         ) : boolean;
 // vMode : 0 : ID, 1 : Name , そのた:ID
  var i : Integer;
      v_Items : Variant;
      vRet : boolean;
begin
  vRet := False;
  Result := vRet;
  if VarIsClear(vDoccument) then exit;
  for i := 0 to ValueLists.Count-1 do
    begin
      case vMode of
        1 : // 1 : Name
            v_Items := vDoccument.getElementsByName(ValueLists.Names[i]);
       else // そのた:ID
            v_Items := vDoccument.getElementById(ValueLists.Names[i]);
      end;  // case vMode
      if VarIsClear(v_Items) then
        begin
          ShowMessage('v_Item null: '+ValueLists.Names[i]);
          Continue;
        end;
    //  ShowMessage(v_Items.length); // 要素の長さ
      if (v_Items.length>=0) then
        begin
         v_Items.Item(0).innerText := ValueLists.ValueFromIndex[i];
         vRet := True;
        end;
    end;
  Result := vRet;
 // v_Items := v.getElementById('ID');
 // v_Items := v.getElementsByName('Name');
 // v_Items := v.getElementsByTagName('body');

end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  //   ListBox1.Items.Add('name'+ '=' + 'Value')
  SetIE_AutoFill(WebBrowser1.Document,ListBox1.Items,1);
end;