CVErr(xlErrValue)
https://xldennis.wordpress.com/2006/11/22/dealing-with-cverr-values-in-net-%e2%80%93-part-i-the-problem/
Dealing with CVErr Values in .NET – Part I: The Problem
Introduction: First of all, I want to thank Dennis for setting me up as a guest author on his “.NET & Excel” blog, which I think is off to a fantastic start. I’m honored to be…
xldennis.wordpress.com
https://xldennis.wordpress.com/2006/11/29/dealing-with-cverr-values-in-net-part-ii-solutions/
Dealing with CVErr Values in .NET – Part II: Solutions
The previous post, Dealing with CVErr Values in .NET – Part I: The Problem, discussed the difficulties we face when manipulating CVErr values such as #N/A when using .NET. If you have not rea…
xldennis.wordpress.com
For example, observe the following VB.NET code:
Dim rngA1 As Excel.Range = xlApp.Range("A1")
Dim rngB1 As Excel.Range = xlApp.Range("B1")
rngA1.Formula = "#N/A" ' rngA1.Value = #N/A
rngB1.Value = rngA1.Value ' rngB1.Value = -2146826246
Excel.xlCVErr Range.Value Coerced to .NET
------------- ----------- ---------------
2000 #NULL! -2146826288
2007 #DIV/0! -2146826281
2015 #VALUE! -2146826273
2023 #REF! -2146826265
2029 #NAME? -2146826259
2036 #NUM! -2146826252
2042 #N/A -2146826246
Imports System.Runtime.InteropServices
Module Helpervb
Enum CVErrEnum As Int32
ErrNull = -2146826288 '2000 #NULL!
ErrDiv0 = -2146826281 '2007 #DIV/0!
ErrValue = -2146826273 '2015 #VALUE!
ErrRef = -2146826265 '2023 #REF!
ErrName = -2146826259 '2029 #NAME?
ErrNum = -2146826252 '2036 #NUM!
ErrNA = -2146826246 '2042 #N/A
End Enum
Function CVErr(whichCVErr As CVErrEnum) As ErrorWrapper
Return New ErrorWrapper(whichCVErr)
End Function
End Module
참고자료
https://docs.microsoft.com/en-us/dotnet/framework/interop/default-marshalling-for-objects
Default Marshalling for Objects - .NET Framework
Understand default marshalling for objects. Review marshalling options. Marshal objects to interfaces or variants, variants to objects, and ByRef variants.
docs.microsoft.com
https://docs.microsoft.com/en-us/dotnet/framework/interop/default-marshalling-behavior
Default Marshalling Behavior - .NET Framework
Learn default marshalling behavior in .NET. Review memory management with interop marshalling, and see default marshalling for classes, delegates, and value types.
docs.microsoft.com
https://docs.microsoft.com/ko-kr/dotnet/api/system.runtime.interopservices.errorwrapper?view=net-6.0
ErrorWrapper 클래스 (System.Runtime.InteropServices)
마샬러가 VT_ERROR으로 마샬링할 개체를 래핑합니다.
docs.microsoft.com
_