Use an enumerator.  In this case, a PlayerBuildingEnum:
// Global Variables
Unit VF1, VF2;
...
// Untested, but should work
SCRIPT_API void CheckForVF2()
{
   // Find the new VF.  Assume VF1 already exists.
   Unit curVF;
   PlayerBuildingEnum vfEnum([AI Player #], mapVehicleFactory);
   // Search through all VFs owned by this player until we find the new one
   while (vfEnum.GetNext(curVF) )
   {
      // Make sure the VF we're looking at isn't VF1
      if (curVF != VF1)
      {
         // Assign this VF with our special handle
         VF2 = curVF;
         // We don't need to run that loop anymore.  Let's get out of it.
         break;
      }
   }
}
  
			
			
			
				I meant something different. After the vehicle factory is destroyed and rebuild, it doesn't work. But I found this code somewhere:
//Find the vecfac if it was rebuilt
    if(vefac.IsLive())//If the handel is dead, then we need to find the new one
    {
    	IUnit Vehfac;
    	InRectEnumerator Rectenum(MAP_RECT(53+31, 191-1, 58+31, 195-1));
    	//Search the area near the vecfac for a new one
        if(Rectenum.GetNext(Vehfac) == 1)
        {
            if(Vehfac.GetType() == mapVehicleFactory)
            {
            	switch(Vehfac.GetBusy())
                {
                    case ctMoDevelop:
                    case ctMoUnDevelop:
                    case ctMoDismantle:
                        break;
                    default://If it's not being built, or destroyed, take it
                        vefac = Vehfac;
                        reinforceGrp.TakeUnit(vefac);
                        break;
                }
            }
        }
    }
 And I think it works now...
But thanks. 
			
			
			
				 I meant something different. After the vehicle factory is destroyed and rebuild, it doesn't work. 
 Uhhh, that's what my code did assuming you also did something like this:
void AIProc()
{
   if (!VF2.IsLive() )
   {
      CheckForVF2();
   }
}
  
			
			
			
				Isn't there the risk of giving a new VF1 the unit handle VF2?
// Make sure the VF we're looking at isn't VF1
      if (curVF != VF1)
Granted, if both VFs are destroyed and then rebuilt, then yeah, what was VF1 may become VF2 and vice-versa, but I really don't see that being a problem since most of the time VFs are built right next to each other anyways.
Edit: Not to mention that code assumes you have more than one VF.  If you've only got the one then no problem.