Sub MID(xSTR1 as string,xSTR2 as string,xPOINT as long,xLEN as long) as string
'第2引数xSTR2=""の場合は参照、有りの場合は置換になります
dim wW1 as string
dim wW2 as string
'check
if xPOINT<0 or _
xLEN<1 or _
xPOINT+xLEN-1>xSTR1.Length then
msgbox(xSTR1&","&xSTR2&","&xPOINT&","&xLEN,"MID_Error")
return 'エラーで終了
end if
'--- Reference ---
if xSTR2="" then
wW1=xSTR1.SubString2(xPOINT-1,xPOINT+xLEN-1)
return wW1
end if
'--- Substitution ---
wW1=xSTR1.SubString2(0,xPOINT-1)
wW2=xSTR1.SubString2(xPOINT+xLEN-1,xSTR1.Length)
return wW1&xSTR2&wW2
End Sub