A homeless man who authorities said robbed and terrorized an elderly woman by breaking into her home in separate incidents a year apart was sentenced to 30 years in prison yesterday by a Montgomery County judge.

Robert E. Myers, 24, who was convicted in March for the second burglary on Aug. 12, 1989, apologized to the victim at the sentencing yesterday, saying "the best part of my life is being taken away from me."

But the victim, a woman in her "early eighties" who pressed the case against Myers, said the burglaries had left her emotionally devastasted. "The second time it happened, I thought, 'So this is the way I'm going to die,' " she said. The victim, who asked that her name not be used, said she has spent more than $3,000 recently for security protection for her house.

"It's like I'm in a jail," she said. "I don't see how a cat could get in now."

Despite emotional pleas from the defendant and his mother, Circuit Court Judge William C. Miller said Myers "constitutes an extreme danger to this community. This was a vicious criminal act on someone who was vulnerable and unable to protect herself."

Miller sentenced Myers to 15-year sentences on separate charges of armed robbery and burglary. They are to be served consecutively. Myers was given concurrent sentences of 10 years each on four other charges.

According to the victim and police, the woman's Chevy Chase house was first burglarized on July 30, 1988. The victim said she was awakened "by this menacing figure dressed all in black standing in my doorway. He had a big stick in his hand." The victim, who was unharmed, was forced to give the burglar $20 from her purse.

Although she installed locks on the rear basement windows after the first incident, she was robbed again on Aug. 12, 1989. "It was just like before except this time he had a hammer in his hand," the woman said. "He ripped the phone from the wall . . . ordered me downstairs, grabbed my purse and ran."

After the second robbery, the assailant allegedly bragged to his friends that "he had done the same thing to the same woman at the same house and that it was easy," according to court documents.

Yesterday, Myers attributed his criminal past to a substance abuse problem that started at age 14. "Every time I use alcohol and drugs, I make the wrong decision and I'm back in here again. I've pushed myself to the point where I'm a three-time loser."

The victim, in a handwritten letter to the judge, said "I still cannot stand to hear breaking glass on television. I stand in fear when the doorbell and telephone ring, and I'm angry that my few remaining years have been so clouded."