Home > database >  Try caoch exception handling
Try caoch exception handling

Time:09-17

PB of dealing with the abnormal data is too little, please give an example, refer to the try caoch how to do? thank you

CodePudding user response:

Try
Iobj. Application. Workbooks. Open (as_sourcepath)
//open file
Lb_open=true

Iobj. Application. DisplayAlerts=False//no prompt to save

//column width adaptive
Iobj. Application. Cells. EntireColumn. AutoFit

The catch (runtimeerror e)
Ls_errtext=um participant etmessage ()
The finally
If lb_open=true then iobj. Application. Workbooks. The Close//if there is no this sentence, excel process may not be able to immediately end
End the try

CodePudding user response:

//take the initiative to throw an error
Try

L_hfile=CreateFile (ls_filename GENERIC_READ, FILE_SHARE_READ, l_Secu [], OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0)
If l_hfile & lt;=0 then
Ls_errtext='CreateFile: + string (l_hfile) +' ~ r ~ n '
THROW the create runtimeerror
End the if

The catch (runtimeerror e)
Ls_errtext +=um participant etmessage ()
The finally
If l_hfile & gt; 0 then
Lb_ret=CloseHandle (l_hfile)
If lb_ret=false then
Ls_errtext +='CloseHandle: + string (lb_ret) +' ~ r ~ n '
//goto e
The else
L_hfile=0
End the if
End the if
End the try

CodePudding user response:

//active throw an error 
Try

L_hfile=CreateFile (ls_filename GENERIC_READ, FILE_SHARE_READ, l_Secu [], OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0)
If l_hfile & lt;=0 then
Ls_errtext='CreateFile: + string (l_hfile) +' ~ r ~ n '
THROW the create runtimeerror
End the if

The catch (runtimeerror e)
Ls_errtext +=um participant etmessage ()
The finally
If l_hfile & gt; 0 then
Lb_ret=CloseHandle (l_hfile)
If lb_ret=false then
Ls_errtext +='CloseHandle: + string (lb_ret) +' ~ r ~ n '
//goto e
The else
L_hfile=0
End the if
End the if
End the try

CodePudding user response:

Try
//language name
The catch (runtimeerror e)
Messagebox (' mistakes', um participant etMessage ())
End the try
  • Related