View Single Post

  #2 (permalink)  
Old 10-14-2002
Anonymous Anonymous is offline
Senior Member
Black Belt
 
Join Date: Jul 2002
Posts: 5,138
Problems with Delphi

Please can someone tell me why I get "...EAccessViolation with message 'Access violation at address 00000000. Read of address 00000000'..." whenever I run this code? (It always happens on the distanceto line.

Code:
  Application.CreateForm(TFMapPoint, FMapPoint);

  FMapPoint.OC1.CreateObject('MapPoint.Map.EU.9', False);
  FMapPoint.OC1.DoVerb(1);
  FMapPoint.OC1.OleObjectInterface.GetUserClassID(vGuid);
  Map := IDispatch(FMapPoint.OC1.OleObject) as _Map;

  mpResults1 := Map.FindResults('WR9 8UH');
  oleCount1 := mpResults1.Count;
  if (oleCount1 < 1) then
  begin
    ShowMessage('No results (1)');
    Exit;
  end;

  oleResult1 := 1;
  ID1 := mpResults1.Item[oleResult1];
  Loc1 := Location(ID1);

  mpResults2 := Map.FindResults('SN8 2QE');
  oleCount2 := mpResults2.Count;
  if (oleCount2 < 1) then
  begin
    ShowMessage('No results (2)');
    Exit;
  end;

  oleResult2 := 1;
  ID2 := mpResults2.Item[oleResult2];
  Loc2 := Location(ID2);


  Dist := Loc1.DistanceTo(Loc2);

  //ShowMessage(FloatToStr(Dist));

  FMapPoint.Release;
  FMapPoint := nil;
Reply With Quote