Here are some synonyms for "vainly":
* Fruitlessly
* Pointlessly
* Uselessly
* In vain
* To no avail
* Without result
Examples:
* "He tried vainly to open the locked door."
* "They searched vainly for the missing child."
* "She pleaded vainly for him to stay."
The word "vain" itself can also mean excessively proud of oneself or one's appearance, but in the context of "vainly," it always relates to lack of success.