function YiJianPinCangAll(sAccount)
dim i
dim BuyHold
dim BuyCost
dim SellHold
dim SellCost
dim CurCode
dim CurMarket
' msgbox "当前持仓数:"&Order.Holding2(sAccount)
Application.MsgOut "111111"
while ( Order.Holding2(Account))
On Error resume Next
HoldStr=""
HoldingCount=Order.Holding2(sAccount)
Application.MsgOut "222222"
If HoldingCount>0 then
For i=0 to HoldingCount-1
Application.MsgOut "33333"
Call Order.HoldingInfo2(i,BuyHolding,BuyCost,BuyTodayHolding,SellHolding,SellCost,SellTodayHolding,PNL,UseMargin,Code,Market,sAccount)
' CurCode=Code
' CurMarket=Market
BuyHold=BuyHolding '持仓品种买入持仓总量
SellHold=SellHolding '持仓品种卖出持仓总量
HoldStr=HoldStr & CurCode
if BuyHold>0 then
HoldStr=HoldStr & " 多单:+" & BuyHold & "手"
call Sell(1,abs(BuyHolding),0,0,Code,Market,sAccount,0) '平多
Application.MsgOut "444444"
end if
if SellHold>0 then
HoldStr=HoldStr & " 空单:-" & SellHold & "手"
call SellShort(1,abs(SellHolding),0,0,Code,Market,sAccount,0)
Application.MsgOut "55555"
end if
HoldStr=HoldStr & " ,"
Next
HoldStr=Left(HoldStr,len(HoldStr)-1) '去掉了尾部,号
End If
' GetHoldStr=HoldStr
wend
DayClose_Label_ZhangHuJieGuo.Caption= "当前品种"&HoldStr &"平仓后,当前持仓数:"&Order.Holding2(sAccount)
Application.MsgOut "666666"
End function
将上述加上调试日志的代码运行后,把运行结果贴过来