|
#1
|
|||
|
|||
|
Automatic saving code
I am trying to end an EXE from a cmdButton, which will automatically save information entered into text box without prompts then quit the program. I can only find information on saving from menus, my program has no Menus. This is my first attempt at VB6 and would be grateful for assistance. My program has 4 Forms with 4/5 text boxes on each which I require to save. Sub cmdExit_Click() SaveMyWork End End Sub What is the code in SaveMyWork ?????? Regards Steve Rowley |
|
#2
|
|||
|
|||
|
Re: Automatic saving code
Hi Rowley,
>save information entered into text box can you be more specific what info and in what kind of file you want to save it? Miro |
|
#3
|
|||
|
|||
|
Re: Automatic saving code
Can you post the code that you found for saving from the menus? It
would be only a very small change to make it work from a command button. LFS "S. Rowley" <Rowleys@teamzeon.com> wrote in message news:3983d843$1@news.devx.com... > > I am trying to end an EXE from a cmdButton, which will automatically save > information entered into text box without prompts then quit the program. > I can only find information on saving from menus, my program has no Menus. > > This is my first attempt at VB6 and would be grateful for assistance. > > My program has 4 Forms with 4/5 text boxes on each which I require to save. > > Sub cmdExit_Click() > SaveMyWork > End > End Sub > > What is the code in SaveMyWork ?????? > > > Regards > > Steve Rowley |
|
#4
|
|||
|
|||
|
Re: Automatic saving code
Greetings Miro, On my form I have 5 Text boxes, txtName, txtAddress, txtCounty, txtZip, txtTel, when information has been entered into the textboxes the person will then Exit the EXE program and the information will be automatically saved without promps of 'save?' Regards Steve "Miroslav St. Jeliazkov" <jeliaskoff@earthling.net> wrote: >Hi Rowley, >>save information entered into text box > >can you be more specific what info and in what kind of file >you want to save it? > >Miro > > |
|
#5
|
|||
|
|||
|
Re: Automatic saving code
Hi Steve Rowley
Try this: ====Code==== Private Sub Form_Unload(Cancel As Integer) Open App.Path & "MyFile.txt" For Output As #1 Print #1, txtName Print #1, txtAddress Print #1, txtCounty Print #1, txtZip Print #1, txtTel Close #1 End Sub ====End Code==== Note that this code opens a file "MyFile.txt" and saves the data but if there was a previous file it will be erased and created again. If you want to add the new data replace the: Open App.Path & "MyFile.txt" For Output As #1 with: Open App.Path & "MyFile.txt" For Append As #1 Hav ei n mind that I show you how to save data in text file. In any other case there is a different way! Miro |
|
#6
|
|||
|
|||
|
Re: Automatic saving code
The two code fragments will need a little modification, but basically they store form controls values to the regisrty and retrieve them back. Call them from the command button after modifying them to perform as desired. (In the code you'll notice that I'm storing ListView Text strings) Replace ME. with another for...each loop and step through each form to make this a universal function. To re-load the values call the get values from the form_load or _Initialize function. If you are trying to write all properties remember that some of them may be read only at run time. Also remember that you must provide a unique key for each property of each control of each form that you are saving. If you use all three names to store the data then you can easily use that information to re-populate the correct controls at run time. D. Public Sub SaveAllItemCollections() Dim xListView As control Dim xListItem As ListItem On Error Resume Next DeleteSetting App.EXEName & LogonClass.DBLogonID For Each xListView In Me.Controls If TypeOf xListView Is ListView Then For Each xListItem In xListView.ListItems Call SaveSetting(App.EXEName & LogonClass.DBLogonID, xListView.Name, xListItem.Index, xListItem.Text) Call SaveSetting(App.EXEName & LogonClass.DBLogonID, xListView.Name, xListItem.Index & "_Text", xListItem.SubItems(1)) Next End If Next End Sub Private Sub GetAllCollectionItems() Dim junkListItem As Variant Dim xListView As Variant Dim i%, xString$, xStringtext$ For Each xListView In Me.Controls If TypeOf xListView Is ListView Then i = 1 xListView.View = lvwReport Do xString = GetSetting(App.EXEName & LogonClass.DBLogonID, xListView.Name, i, -1) xStringtext = GetSetting(App.EXEName & LogonClass.DBLogonID, xListView.Name, i & "_Text", -1) If xStringtext = "-1" Then Exit Do Else Set junkListItem = xListView.ListItems.Add(, , xString) junkListItem.SubItems(1) = xStringtext End If i = i + 1 Loop End If Next End Sub "S. Rowley" <Rowleys@teamzeon.com> wrote: > >I am trying to end an EXE from a cmdButton, which will automatically save >information entered into text box without prompts then quit the program. >I can only find information on saving from menus, my program has no Menus. > >This is my first attempt at VB6 and would be grateful for assistance. > >My program has 4 Forms with 4/5 text boxes on each which I require to save. > >Sub cmdExit_Click() > SaveMyWork > End >End Sub > >What is the code in SaveMyWork ?????? > > >Regards > >Steve Rowley |
|
#7
|
|||
|
|||
|
Re: Automatic saving code
> This is my first attempt at VB6 and would be grateful
> for assistance. Steve: We have a newsgroup specifically for people who are new to VB: vb.getting.started. The participants in that group are accustomed to giving very detailed, step-by-step answers to beginners' questions. In the future, you're more likely to get the help you need if you post your questions there. Welcome to the DevX discussions! --- Phil Weber DevX.com, Inc. |
|
#8
|
|||
|
|||
|
Re: Automatic saving code
Greetings Miro, Thanks for you response. What I am trying to achieve is, 1.E-mail the file to clients. 2.Clients complete the file eg enter data into the text boxes, press the exit button, automatically save the changes. 3.E-mail the file back to me with the updated information, which I will then rename the returned file. The project is called Myfile, the form is called Myform The ideal solution for myself would be: ====Code==== Private Sub cmdExit_Click() Myfile.Save 'Obviously this does not work ????? End End Sub ====End Code==== Thanks for your patience Steve "Miroslav St. Jeliazkov" <jeliaskoff@earthling.net> wrote: >Hi Steve Rowley > >Try this: >====Code==== > >Private Sub Form_Unload(Cancel As Integer) > Open App.Path & "MyFile.txt" For Output As #1 > Print #1, txtName > Print #1, txtAddress > Print #1, txtCounty > Print #1, txtZip > Print #1, txtTel > Close #1 >End Sub > >====End Code==== > >Note that this code opens a file "MyFile.txt" and saves the >data but if there was a previous file it will be erased and >created again. If you want to add the new data replace the: > >Open App.Path & "MyFile.txt" For Output As #1 > >with: > >Open App.Path & "MyFile.txt" For Append As #1 > >Hav ei n mind that I show you how to save data in text file. >In any other case there is a different way! > >Miro > > |
|
#9
|
|||
|
|||
|
Re: Automatic saving code
I see,
now in that procedure the last thing your app do is to save in that txt file your information. After Close #1 you have to use MAPI or SMTP to send as attachment that file (MyFile.txt) ===Begin of code=== Private Sub Form_Unload(Cancel As Integer) Open App.Path & "MyFile.txt" For Output As #1 Print #1, txtName Print #1, txtAddress Print #1, txtCounty Print #1, txtZip Print #1, txtTel Close #1 'New code With mpsMail .DownLoadMail = False .LogonUI = True .SignOn .NewSession = True mpmMail.SessionID = .SessionID End With With mpmMail .Compose .AttachmentPathName = "MyFile.txt" .RecipAddress = "email@server" 'change that .AddressResolveUI = True .ResolveName .msgSubject = "User Responce of my app" 'This is the subject .MsgNoteText = "your text here" 'Atleast 1 letter because 'the attachment wants it .Send False End With mpsMail.SignOff End Sub ====End Code==== mpsMail is the name of MAPI Session and mpmMail of MAPI Message (components to add from the toolbox so you can send e-mails. On the PC you have to have e-mail program installed and set to default. If the user don't has so you have to swich the code to sending SMTP Mail but thats rather different. Bye for now, Miro |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|