in reply to How to reduce this lengthy code?

Hi HongPing,

How do you know it's lengthy, maybe it's not long enough?

It's nice that you have named variables, but your comments are sparse, your code is not SO nice that everyone will immediately know what it should do. I don't see any indentation or loops. If you want people's help, it is important to show maintainable code, even for yourself when you come back to fix something in a year's time, comments will help you. Some people write code that is just perfect and intuitive, but for the rest of us: we need comments.

Good luck

Steve.