Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 339
Default Range vs IRange What's the difference?

Hi

I found a C# example of an Excel add-in at
http://www.codeproject.com/dotnet/excelnetauto.asp. I made some changes to
this project and made a function that takes an Excel.Range as a parameter.

Intellisense showed that there is an interface called IRange as well as
Range. What's the difference? When would you want to use an IRange?

TIA,
Fredrik


Here's my added C# function.


public int GetRangeSize1(Excel.Range range)
{

return range.Columns.Count * range.Rows.Count;

}


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 252
Default Range vs IRange What's the difference?

IRange is neither an Excel or VBA object, method or property.
As far as I know the only way it could be used in the above is as a Variable
as in

Sub GetIRangeValue()
Dim IRange as Integer
Dim Rng as Range

Set Rng = Sheet1.Range("A1")
IRange = Rng.Value
Msgbox IRange
End Sub

"Fredrik Wahlgren" wrote:

Hi

I found a C# example of an Excel add-in at
http://www.codeproject.com/dotnet/excelnetauto.asp. I made some changes to
this project and made a function that takes an Excel.Range as a parameter.

Intellisense showed that there is an interface called IRange as well as
Range. What's the difference? When would you want to use an IRange?

TIA,
Fredrik


Here's my added C# function.


public int GetRangeSize1(Excel.Range range)
{

return range.Columns.Count * range.Rows.Count;

}



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 339
Default Range vs IRange What's the difference?

No, you have dim'ed Irange as as an integer. If you use VB6 or VB.NET you
can do this

Dim r as Excel.Irange

C#

Excel.IRange r;

It compiles fine but I don't understand how I would use this variable.
IRange will also appear if you use the OLE/COM Object viewer and create an
idl file from excel.exe

/Fredrik



"gocush" /delete wrote in message
...
IRange is neither an Excel or VBA object, method or property.
As far as I know the only way it could be used in the above is as a

Variable
as in

Sub GetIRangeValue()
Dim IRange as Integer
Dim Rng as Range

Set Rng = Sheet1.Range("A1")
IRange = Rng.Value
Msgbox IRange
End Sub

"Fredrik Wahlgren" wrote:

Hi

I found a C# example of an Excel add-in at
http://www.codeproject.com/dotnet/excelnetauto.asp. I made some changes

to
this project and made a function that takes an Excel.Range as a

parameter.

Intellisense showed that there is an interface called IRange as well as
Range. What's the difference? When would you want to use an IRange?

TIA,
Fredrik


Here's my added C# function.


public int GetRangeSize1(Excel.Range range)
{

return range.Columns.Count * range.Rows.Count;

}





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 252
Default Range vs IRange What's the difference?

Sorry, I thought you were asking how IRange could be used in programing VBA.
In vba the first letter "i" or "I" is usually used to indicate that you
have dimmed your variable as an integer - as in my example. This is not
absolutely required but good programming practice.

As for programming in C# as you are doing, that is beyond the scope of this
forum and should be posted to an appropriate forum.

"Fredrik Wahlgren" wrote:

No, you have dim'ed Irange as as an integer. If you use VB6 or VB.NET you
can do this

Dim r as Excel.Irange

C#

Excel.IRange r;

It compiles fine but I don't understand how I would use this variable.
IRange will also appear if you use the OLE/COM Object viewer and create an
idl file from excel.exe

/Fredrik



"gocush" /delete wrote in message
...
IRange is neither an Excel or VBA object, method or property.
As far as I know the only way it could be used in the above is as a

Variable
as in

Sub GetIRangeValue()
Dim IRange as Integer
Dim Rng as Range

Set Rng = Sheet1.Range("A1")
IRange = Rng.Value
Msgbox IRange
End Sub

"Fredrik Wahlgren" wrote:

Hi

I found a C# example of an Excel add-in at
http://www.codeproject.com/dotnet/excelnetauto.asp. I made some changes

to
this project and made a function that takes an Excel.Range as a

parameter.

Intellisense showed that there is an interface called IRange as well as
Range. What's the difference? When would you want to use an IRange?

TIA,
Fredrik


Here's my added C# function.


public int GetRangeSize1(Excel.Range range)
{

return range.Columns.Count * range.Rows.Count;

}






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Range vs IRange What's the difference?

Fredrik,
Recently I wrote a sets of classes that all Implement my "IBarCodeFormat"
interface.

This allows you to write something like:
Dim ThisBarCodeFormat as IBarCodeFormat

Set ThisBarCodeFormat =New EAN13
or
Set ThisBarCodeFormat =New EAN8
or
Set ThisBarCodeFormat =New Code39

as you can be sure that the class signatures will match the interface (by
definition)

So for you, I would guess the class "Range" Implements the "IRange"
interface. However, I'm not sure if that is any use to you, unless may be
you wanted to write your own "MyRange" class that had the same signature as
Excel's, but different functionality.

This is from a VB/VBA perspective on using Implements. C# or VB.Net may well
be different due to their appraoch to object, inheritance etc.

NickHk

"Fredrik Wahlgren" wrote in message
...
No, you have dim'ed Irange as as an integer. If you use VB6 or VB.NET you
can do this

Dim r as Excel.Irange

C#

Excel.IRange r;

It compiles fine but I don't understand how I would use this variable.
IRange will also appear if you use the OLE/COM Object viewer and create an
idl file from excel.exe

/Fredrik



"gocush" /delete wrote in message
...
IRange is neither an Excel or VBA object, method or property.
As far as I know the only way it could be used in the above is as a

Variable
as in

Sub GetIRangeValue()
Dim IRange as Integer
Dim Rng as Range

Set Rng = Sheet1.Range("A1")
IRange = Rng.Value
Msgbox IRange
End Sub

"Fredrik Wahlgren" wrote:

Hi

I found a C# example of an Excel add-in at
http://www.codeproject.com/dotnet/excelnetauto.asp. I made some

changes
to
this project and made a function that takes an Excel.Range as a

parameter.

Intellisense showed that there is an interface called IRange as well

as
Range. What's the difference? When would you want to use an IRange?

TIA,
Fredrik


Here's my added C# function.


public int GetRangeSize1(Excel.Range range)
{

return range.Columns.Count * range.Rows.Count;

}







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


Similar Threads
Thread Thread Starter Forum Replies Last Post
sum the difference in a range carla Excel Worksheet Functions 2 November 21st 07 05:57 PM
Date Range & Difference pm_arrow Excel Worksheet Functions 2 October 29th 07 02:51 PM
Count difference based on Range Richhall Excel Worksheet Functions 2 September 5th 07 12:06 PM
Labelling a row so it can be used as an offset for sum, difference or range Martin Underwood Excel Discussion (Misc queries) 5 March 18th 05 04:37 PM
Difference between range.formula and range.formulalocal Andy Excel Programming 3 May 1st 04 07:26 PM


All times are GMT +1. The time now is 11:05 PM.

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

About Us

"It's about Microsoft Excel"