A completion procedure for computing a canonical basis for a k-subalgebra is proposed. Using this canonical basis, the membership problem for a k-subalgebra can be solved. The approach follows Buchberger's approach for computing a Groebner basis for a polynomial ideal and is based on rewriting concepts. A canonical basis produced by the completion procedure shares many properties of a Groebner basis such as reducing an element of a k-subalgebra to 0 and generating unique normal forms for the equivalence classes generated by a k-subalgebra. In contrast to Shannon and Sweedler's approach using tag variables, this approach is direct. One of the limitations of the approach however is that the procedure may not terminate for some term orderings thus giving an infinite canonical basis. The procedure is illustrated using examples.