PB處理例外的資料太少了,請大家給個例子參考參考,try caoch怎么用?謝謝
uj5u.com熱心網友回復:
tryiobj.application.workbooks.Open( as_sourcepath )
//已打開檔案
lb_open=true
iobj.Application.DisplayAlerts = False //不提示保存
//列寬自適應
iobj.application.Cells.EntireColumn.AutoFit
catch(runtimeerror e)
ls_errtext=e.getmessage()
finally
if lb_open=true then iobj.application.Workbooks.Close //如果沒有此句,excel行程可能不能立即結束
end try
uj5u.com熱心網友回復:
//主動拋出錯誤try
l_hfile=CreateFile(ls_filename,GENERIC_READ,FILE_SHARE_READ,l_Secu[],OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0)
if l_hfile<=0 then
ls_errtext='CreateFile:'+string(l_hfile)+'~r~n'
THROW create runtimeerror
end if
catch(runtimeerror e)
ls_errtext+=e.getmessage()
finally
if l_hfile>0 then
lb_ret=CloseHandle(l_hfile)
if lb_ret=false then
ls_errtext+='CloseHandle:'+string(lb_ret)+'~r~n'
//goto e
else
l_hfile=0
end if
end if
end try
uj5u.com熱心網友回復:
//主動拋出錯誤
try
l_hfile=CreateFile(ls_filename,GENERIC_READ,FILE_SHARE_READ,l_Secu[],OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0)
if l_hfile<=0 then
ls_errtext='CreateFile:'+string(l_hfile)+'~r~n'
THROW create runtimeerror
end if
catch(runtimeerror e)
ls_errtext+=e.getmessage()
finally
if l_hfile>0 then
lb_ret=CloseHandle(l_hfile)
if lb_ret=false then
ls_errtext+='CloseHandle:'+string(lb_ret)+'~r~n'
//goto e
else
l_hfile=0
end if
end if
end try
uj5u.com熱心網友回復:
try//語名
catch ( runtimeerror e )
messagebox('錯誤', e.GetMessage())
end try
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/43282.html
標籤:腳本語言
