Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 269
Default CVErr, Excel and VB .NET

Many Excel macros/add-ins rely on the use of the VB/VBA CVErr function.

Alas, VB .NET does not support the CVErr function.

Does Excel 2003, Office 2003 or Visual Studio Tools for Office provide a
substitute?

--
http://www.standards.com/; See Howard Kaikow's web site.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 170
Default CVErr, Excel and VB .NET


"Howard Kaikow" wrote in message
...
Many Excel macros/add-ins rely on the use of the VB/VBA CVErr function.

Alas, VB .NET does not support the CVErr function.

Does Excel 2003, Office 2003 or Visual Studio Tools for Office provide a
substitute?


But in .net you can achieve the same functionallity
by using the exception handling routines it does support

In VB6 you'd call a VB error code as follows

Function CalculateDouble(Number)
If IsNumeric(Number) Then
CalculateDouble = Number * 2 ' Return result.
Else
CalculateDouble = CVErr(2001) ' Return a user-defined error
End If ' number.
End Function


In .net you'd throw an exception to do the same thing
with the call

Throw new InvalidOperationException("Invalid Input to Function")

Keith


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 269
Default CVErr, Excel and VB .NET

Yes, I recall, perhaps incorrectly, that special error codes in Excel, such
as xlErrValue, required use of a Variant.

--
http://www.standards.com/; See Howard Kaikow's web site.
"Keith Willshaw" wrote in message
...

"Howard Kaikow" wrote in message
...
Many Excel macros/add-ins rely on the use of the VB/VBA CVErr function.

Alas, VB .NET does not support the CVErr function.

Does Excel 2003, Office 2003 or Visual Studio Tools for Office provide a
substitute?


But in .net you can achieve the same functionallity
by using the exception handling routines it does support

In VB6 you'd call a VB error code as follows

Function CalculateDouble(Number)
If IsNumeric(Number) Then
CalculateDouble = Number * 2 ' Return result.
Else
CalculateDouble = CVErr(2001) ' Return a user-defined error
End If ' number.
End Function


In .net you'd throw an exception to do the same thing
with the call

Throw new InvalidOperationException("Invalid Input to Function")

Keith




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 03:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"