Re: Confused about OOP programming!

Stacey Levine <[email protected]>
Newsgroups gmane.comp.windows.devel.dotnet.winforms
Message-ID <A48E95FB3D4D02449554AE952F3B3E4702FC43CB@vmcexchng.www.musicforasong.net>
Abosultely don't assume that the file is open, but you have a reference
to it and you can check it's state.. 

Ie.. IsNothing(_excelHandle) = False   then set the file

And if it is true, you can check it's open state.

-----Original Message-----
From: Discussion forum for developers using Windows Forms to build apps
and controls [mailto:[email protected]] On Behalf Of
Stuart Laughlin
Sent: Friday, March 30, 2007 11:26 AM
To: [email protected]
Subject: Re: [DOTNET-WINFORMS] Confused about OOP programming!

I attempted to send this yesterday, but it never appeared on the list...

On 3/29/07, Steve Abaffy <[email protected]> wrote:
>
> Now the problem I see here is that I am open and closing the same file
> twice.

Why is that a problem? I do the analogue with databases all the time
(i.e. open a connection, read some records, close the connection, user
selects record of interest, open a connection, read some detail
records, close the connection, etc).

> I can of course get around this problem by using a global
InputExcelObj but
> that seems to violate the do not use global variable rule.

As Stacey suggested, you could indeed use a private class-level
identifier to reference the Excel object. I think it's asking for
trouble, though. If you go this route, you still ought not to assume
that the file remains open and accessible via the class-level
identifier when the user clicks the 'process file' button.

>
> What is a better way to do this? And of course if one could use a
> ExcelObjClass where you can have methods like GetCellValue, SaveFile,
> OpenFileforRead, OpenFileForWrite etc... that would be even better.

Aren't those methods (or something very similar) already part of the
API?

http://msdn2.microsoft.com/en-us/library/aa168292(office.11).aspx


--Stuart
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.