The present invention provides a use of a compound to prepare a pharmaceutical composition for treating abnormal β-amyloid aggregation mediated diseases. The compound is represented by the following formula (I):wherein A, B, R1, R2, R3, R4, R5 and R6 are defined in the specification.