Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Visual Basic 2012 Programmer's Reference
This is the forum to discuss the Wrox book Visual Basic 2012 Programmer's Reference by Rod Stephens; ISBN: 978-1-1183-1407-4
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Visual Basic 2012 Programmer's Reference section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old November 9th, 2012, 05:21 PM
Authorized User
Points: 193, Level: 3
Points: 193, Level: 3 Points: 193, Level: 3 Points: 193, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2011
Posts: 31
Thanks: 6
Thanked 0 Times in 0 Posts
Question Properly closing a file

Hi Rod,

It's been a long time since I checked in with you. When I was writing to you before one of my questions was how to save the contents in a TreeView box so that it could be reloaded later on. This would be for a situation in which the user creates the TreeView List while running the program (not written into the code). You gave me some ideas and I finally was able to do it. I can create the list in TreeView, Edit, Save it and Open it.

There is only one problem left that stumps me. As long as I close out the application completely before I open a file there is no problem. However, it seems to me that I should be able to work with a file, close the file and open it again without closing the entire application. Just like in Microsoft Word, you can open a file or start a new one, edit it, and close the file without leaving MicroSoft Word.

I assume that even though I clear all of the Text Boxes, TreeView Box, List Boxes and so on, so that everything looks like it did before I opened the file, there must be something in the code that is not going back to its previous state. Otherwise, why do I get a different result when I open a file immediately after starting the application than I do when I open a file after saving it and without leaving the application?

I would appreciate Any insight you can give me in this connection.

Sincerely,


Gary
Reply With Quote
  #2 (permalink)  
Old May 20th, 2013, 11:16 AM
Rod Stephens's Avatar
Wrox Author
Points: 3,145, Level: 23
Points: 3,145, Level: 23 Points: 3,145, Level: 23 Points: 3,145, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
Posts: 641
Thanks: 2
Thanked 96 Times in 95 Posts
Default

Sorry for the long delay. I didn't see this post.

Quote:
There is only one problem left that stumps me. As long as I close out the application completely before I open a file there is no problem. However, it seems to me that I should be able to work with a file, close the file and open it again without closing the entire application. Just like in Microsoft Word, you can open a file or start a new one, edit it, and close the file without leaving MicroSoft Word.

I assume that even though I clear all of the Text Boxes, TreeView Box, List Boxes and so on, so that everything looks like it did before I opened the file, there must be something in the code that is not going back to its previous state. Otherwise, why do I get a different result when I open a file immediately after starting the application than I do when I open a file after saving it and without leaving the application?
How is the file different?

If you write into a file, the text may not actually be written to the disk right away. Instead the system may buffer the data and then write it later when the buffer is full. This is more efficient than writing the data immediately because that would force the program to wait for the relatively slow disk drive.

All this means if the program crashes or exits without flushing or closing the file, some of the data you wanted to write into it may be lost.

So the program should always close the file before exiting.

If you close and reopen the file, it should look the same as if the program had closed and then restarted.

I hope that help. Sorry again for the long delay.
__________________
Rod

Rod Stephens, Microsoft MVP

Essential Algorithms: A Practical Approach to Computer Algorithms

(Please post reviews at Amazon or wherever you shop!)
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Check Boxes: Writing Results to Text File and Formatting Properly jdanniel Beginning VB 6 1 May 29th, 2011 08:55 PM
Closing A File When Someone Else Is Using It shortland Excel VBA 1 September 25th, 2007 04:27 PM
Doesn't work properly for multiple file arguments. sbubendorf VBScript 7 September 20th, 2007 08:52 AM
Closing an ADO connection to a .DBF file tknnguyen Pro VB 6 2 July 25th, 2007 01:49 PM
Scheduled VBS file is not working properly bsrini SQL Server 2000 16 April 14th, 2004 04:09 AM



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


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