Function Bits2Num Lparameters tcBinary LOCAL ix,lnNum,lnLen lnNum = 0 lnLen = Len(m.tcBinary) For ix=1 To Occurs('1',m.tcBinary) lnNum = BITSET(m.lnNum, m.lnLen-At('1',m.tcBinary,m.ix)) endfor Return m.lnNumString operations are slow in VFP and for any language in general. Why do you store it in a bin string? To me it looks like both a storage and performance loss. If you absolutely must and have a need for performance then probably you would want to create a FLL or .Net com for it (like Sedna Net4com)?