p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Stephens' Visual Basic Programming 24-Hour Trainer (http://p2p.wrox.com/forumdisplay.php?f=621)
-   -   Ex 21-3 SimpleEdit modification (http://p2p.wrox.com/showthread.php?t=84914)

zavodney September 1st, 2011 12:13 AM

Ex 21-3 SimpleEdit modification
The exercise in the book says "... To test the program, open the file Test.rtf in Microsoft Word. Make changes in the SimpleEdit program and try to save them into that file. ...". I don't have Word, so I used WordPad. Your program (and mine) allows me to save it in that file without giving me an error. I then close WordPad and reopen the file in WordPad and the changes were made. I inferred from the excerpted statement that the program would throw an error. Is that what was implied or did I read that statement incorrectly? Would this have worked differently in Word?

Keith Z.

Rod Stephens September 1st, 2011 10:02 AM

Hi Keith,

Yes, the result is different in Word. Word has a fancier file manipulation model so when it has a file open for editing it locks the file. If a program tries to open a file locked by Word, it will fail.

WordPad doesn't lock the files it has open so your program will be able to open the file.

As an alternative test, set a breakpoint in the program on the statement that opens the file. Run to that point and then rename or delete the file before continuing. The program should fail to open the file (because it is no longer there) and the error handling code should deal with it.

zavodney September 1st, 2011 08:24 PM

OK, Thanks.

Keith Z.

All times are GMT -4. The time now is 02:02 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.