Results 1 to 8 of 8

Thread: Save As..........(Forms)

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2000
    Posts
    64

    Exclamation

    I would like to save the whole form when the application is running. According to the VB help file, all you need to do is enter:

    form1.saveas nameoffile

    but this command does not work. I just want them to be able to save and load the whole form, with like the tesxt boxes filled in with what they entered when they saved.

    Any help would be appreciated.

    Thanks
    Wrestlecar

  2. #2
    Addicted Member
    Join Date
    Jan 2000
    Location
    Sydney, Australia
    Posts
    196

    Wink

    I don't think the "SaveAs" method applies to the Form object. If you look at the help for the "SaveAs" method and then click on "Applies To" you'll get a list of the objects the method can be used with - but unfortunately the "form" is not one of these objects.

    The other hint is that when you type "form1." and then the list appears - "SaveAs" is not in the list.

    I have had to save the user's data before so that when they run the program again it is displayed as it was before. The way i did it was to just save all the strings to a text file and then read them back next time the project opens (doesn't have to be just strings).

    The preferred method would be to use the "SaveSetting" function to save the data to the registry. Use "GetSetting" to get them back. The reason i did not do it this way is that IT would not go anywhere near an application that touched the "sacred" registry. But that really is the [current] way to do it. The older way would be to use a .ini file - same sort of thing - .ini files were about before the registry became more openly accessible to programmers like us.

    Hope this helps - although you never really like to see a reply with no code...

    Mark

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    What do you mean with Save form?
    1. If you mean to save some settings of the form the registry is good for you, or an ini file
    2. If you mean to save the outlook of it, use bitblt api to copy the window area of it (maybe you have to use getwindowrect), and put it in a picture and save it with savepicture
    3. If you need to save the controls position and/or data you could loop trough all items in controls property of the form and test their properties to save them by under the name property.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Apr 2000
    Posts
    64
    Let me try to clear this up.


    I have about 60 text boxes on the form, and they enter stuff in them. To save them from retyping the information, i would like them to be able to save those words and calculations in the text boxes.

    Any help, some code would be appreciated...

    Thanks

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Apr 2000
    Posts
    64
    This is from the Visual Basic 4 help file:
    ---------------------------

    SaveAs Method (Add-In)

    Saves a component using a new filename. Doesn't support named arguments.


    Syntax

    object.SaveAs newfilename

    The SaveAs method syntax has these parts:

    Part Description

    object An object expression that evaluates to an object in the Applies To list.
    newfilename Required. A string expression specifying the new filename for the component to be saved. If the new filename is invalid or refers to a read-only file, an error occurs.

    Remarks

    When a form is saved, newfilename specifies the new name of the form file itself; the .FRX file, if applicable, is saved automatically with the .FRX extension.

    Note Successfully invoking this method causes the associated events from the FileControl object to be invoked.



    I would like to save the form as .frx if it is possible.

  6. #6
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926
    This method can be used in the VB IDE only. You have to add a reference to Microsoft Visual Basic 6.0 Extensibility. Because it can be used only if the IDE is open, it is especially usefull when you are developing add-ins for visual basic. This method can not be used to save forms running from an executable.

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Apr 2000
    Posts
    64
    How can i save the info in the text boxes then?

  8. #8
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    open a file output, go trough all textboxes, print them in the file, close it
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width