-
Nov 21st, 2021, 09:01 AM
#1
Thread Starter
Lively Member
Type Text Box In Form1 and Copied It to Form 2, Then Next Run Only Form 2 is Appears
Hi Member,
I need some help here.I have 2 form, say it Form 1 and Form 2, either into a form there is 1 text box and 1 button, first run the program/app Form 1 is appears then I write some letter into a text box (form 1), then toggle the button in Form 1 and Form 1 will closed and appears Form 2 with a copy a letter text box from Form 1.
My question is, what can I do for next time or next run? The program Form 1 could not appear anymore, only appears Form 2, except it a Form 1 .. I called it back by toggling the button from Form 2.
Baj.
Type Text In Form1 and Copied it to Form2.zip
-
Nov 21st, 2021, 09:38 AM
#2
Fanatic Member
Re: Type Text Box In Form1 and Copied It to Form 2, Then Next Run Only Form 2 is App
You have me confused!
I assume this is an SDI NOT MDI Application.
If SDI you are going to have a StartUP Form.
I assume that StartUp Form is Form1.
If you create another Form, based on your narrative you've named it Form2.
Now I also assume on both Form1 and Form2 you have a textbox and a Command Button.
So when you write something in the textbox in Form1 and press Form1 command button it is copied to the textbox in Form2.
If the above is correct, then you have me confused from this point on.
If you stop your App and restart, since Form1 is the StartUp Form, Form1 should again reappear???
-
Nov 21st, 2021, 10:33 AM
#3
Thread Starter
Lively Member
Re: Type Text Box In Form1 and Copied It to Form 2, Then Next Run Only Form 2 is App
Originally Posted by vb6forever
You have me confused!
I assume this is an SDI NOT MDI Application.
If SDI you are going to have a StartUP Form.
I assume that StartUp Form is Form1.
If you create another Form, based on your narrative you've named it Form2.
Now I also assume on both Form1 and Form2 you have a textbox and a Command Button.
So when you write something in the textbox in Form1 and press Form1 command button it is copied to the textbox in Form2.
If the above is correct, then you have me confused from this point on.
If you stop your App and restart, since Form1 is the StartUp Form, Form1 should again reappear???
vb6forever,
Yes, Form1 is StartUp Form.
-> Now I also assume on both Form1 and Form2 you have a textbox and a Command Button.
# Yes true.
->So when you write something in the textbox in Form1 and press Form1 command button it is copied to the textbox in
Form2.
# Yes true.
-> If you stop your App and restart, since Form1 is the StartUp Form, Form1 should again reappear??
# That is my point.
# Once it app is restart it should be Form 2 is run and no more Form 1, except I called it back from Form 2 with toggle
the button.
# I think this can do, but I do not know how to do.
Baj.
-
Nov 21st, 2021, 12:29 PM
#4
Fanatic Member
Re: Type Text Box In Form1 and Copied It to Form 2, Then Next Run Only Form 2 is App
That is what "StartUp" form means. The App when started has to load something first. You could create a Main which on load would read a value and respond to that value using some type of variable that would then load Form1 OR Form2.
BUT what is the objective (???) for wanting to load a different form at startup?
You can create a Visual Basic 6 program to run without any form.
You need to create a module. Put a Public Sub Main inside of it.
Then in under Project Properties, General Tab; change the startup object to be Sub Main.
Last edited by vb6forever; Nov 21st, 2021 at 12:35 PM.
-
Nov 21st, 2021, 12:49 PM
#5
Re: Type Text Box In Form1 and Copied It to Form 2, Then Next Run Only Form 2 is App
Yep Sub Main as startup then load the form you want from there but if these 2 forms have only one button and one text box and the data from the text box is to be transfered to the other form is there really any reason to have two forms at all?
-
Nov 21st, 2021, 06:24 PM
#6
Thread Starter
Lively Member
Re: Type Text Box In Form1 and Copied It to Form 2, Then Next Run Only Form 2 is App
Originally Posted by vb6forever
That is what "StartUp" form means. The App when started has to load something first. You could create a Main which on load would read a value and respond to that value using some type of variable that would then load Form1 OR Form2.
BUT what is the objective (???) for wanting to load a different form at startup?
vb6forever,
I continue this project (that solved by SOB) with additional form, my plan is before run to main form, first run is to starUp form like you said and Datamiser on previous post, once this StartUp form is filled (Text Box 1 for Title and Text Box 2 for Name) then automatically this will filled to Text Box 3, If Text Box 4 value is true then valid to disappears for StartUp Form and for next run a Main Form will appears.
I know this is something like encrypted and decrypted or a registration app, but really I am not going there, for this there is separate form with different handling.
-.>BUT what is the objective (???) for wanting to load a different form at startup # That is a good question, my goal is before they go to the main program, they already type the name of Title or something into Main Form.
See attached, as well to my first post, I am sure it can't do, but with this revised I am sure I can do.
The point is, write it in a text box then save it to the path folder as a txt file then call it back to filled TextBox 4, once it is true then disappears StartUp Form for next run.
Baj.
Type Text In Form1 and Copied it to Form2_1.zip
-
Nov 21st, 2021, 06:34 PM
#7
Thread Starter
Lively Member
Re: Type Text Box In Form1 and Copied It to Form 2, Then Next Run Only Form 2 is App
Originally Posted by DataMiser
Yep Sub Main as startup then load the form you want from there but if these 2 forms have only one button and one text box and the data from the text box is to be transfered to the other form is there really any reason to have two forms at all?
DataMiser,
Refer to my first post and attachment, I am sure it's so difficult, please see my second attachment.
In my revision, I add more text box and I write a path folder to save a txt file, my hope with this method it will be filled into Text Box 4.
I remember how to make a registration app or decryption and encryption, perhaps with this method it can do, but a problem for me is how to fill it or call it back automatically.
Could someone here have another method more easy and simple.
Baj.
-
Nov 21st, 2021, 06:44 PM
#8
Thread Starter
Lively Member
Re: Type Text Box In Form1 and Copied It to Form 2, Then Next Run Only Form 2 is App
Originally Posted by dilettante
Well most Windows applications would make use of the well-established "dialog pattern" for this sort of thing... assuming I have decoded the actual intent.
It sounds like the program needs to request and save some "first run" data that it silently retrieves subsequently. You can put nearly all of that logic into the secondary dialog Form.
This demo has a menu item for deleting the saved data to making testing multiple runs easier.
- Run it, cancel the data request.
- Run it again, providing the data.
- Run it again, and it goes ahead and uses the saved data.
- Delete the saved data, run it yet again, and it requests the data again.
A real program would probably store the data under a per-user or common folder. Here for simplicity I just used App.Path to hold the saved data file.
Dilettante,
Yes, it's true.This needs to be written into Text Box 2 then stored it to the path with txt format, dat format or bat format, whichever one we wish to use it, once is stored then will called it back automatically to filled into Text Box 4, if it true then StartUp Form will disappears for next run, the only Main Form will run, except for sample it can call back by button at Main Form, but it's not necessary.
Anyway I will try your attachment here, I will see it.
Baj.
-
Nov 21st, 2021, 07:20 PM
#9
Thread Starter
Lively Member
Re: Type Text Box In Form1 and Copied It to Form 2, Then Next Run Only Form 2 is App
Originally Posted by dilettante
Well most Windows applications would make use of the well-established "dialog pattern" for this sort of thing... assuming I have decoded the actual intent.
It sounds like the program needs to request and save some "first run" data that it silently retrieves subsequently. You can put nearly all of that logic into the secondary dialog Form.
This demo has a menu item for deleting the saved data to making testing multiple runs easier.
- Run it, cancel the data request.
- Run it again, providing the data.
- Run it again, and it goes ahead and uses the saved data.
- Delete the saved data, run it yet again, and it requests the data again.
A real program would probably store the data under a per-user or common folder. Here for simplicity I just used App.Path to hold the saved data file.
Dilettante,
Your test code is true, you stored by type to Text Box then stored it to a path with txt format with name TheData, it means once text box is filled then record it value then stored it.
But a problem is txt value into TheData path should be called back, so need to called by Form_Load into the MainForm, I tried to copy it "GetAttr "TheData.txt"" and other
Code:
F = FreeFile(0)
Open "TheData.txt" For Input As #F
Line Input #F, TheData
Close #F
But it doesn't work, my question too is how to call it back, automatically with no need to use a delete button.
Baj.
-
Nov 22nd, 2021, 03:31 AM
#10
Thread Starter
Lively Member
Re: Type Text Box In Form1 and Copied It to Form 2, Then Next Run Only Form 2 is App
Hi Member,
Please see a video, I just think the method is the same as it, in a video there needs to be a separate form to make it activated and then next run the main program will show first, no more appears StartUp Form.
What I wish is to make only a single, not 2 apps like a video.
My goal is, a user writes in StartUp Form then writes some letter into Text Box and copies it to Main Form, next run no more StarUp Form appears.
My second attachment, I tried to create txt file and store it to path, that is similar method like "Dilettante", but there is can't how to called it automatically....because I don't know how to do it ?
Baj.
-
Nov 22nd, 2021, 09:16 AM
#11
Re: Type Text Box In Form1 and Copied It to Form 2, Then Next Run Only Form 2 is App
As was mentioned earlier you can create a module and in that module create a sub main() then make that your startup. In sub Main you add code to check for and read your file. If it does not exist show your form1. If it does exist then read it and check to see if the data within is valid. If it is valid then show your form2. If it is not valid then perhaps display a message and then show your form1.
-
Nov 23rd, 2021, 01:51 AM
#12
Thread Starter
Lively Member
Re: Type Text Box In Form1 and Copied It to Form 2, Then Next Run Only Form 2 is App
Originally Posted by DataMiser
As was mentioned earlier you can create a module and in that module create a sub main() then make that your startup. In sub Main you add code to check for and read your file. If it does not exist show your form1. If it does exist then read it and check to see if the data within is valid. If it is valid then show your form2. If it is not valid then perhaps display a message and then show your form1.
DataMiser,
Well noted, I will try it.
Could this be without using a module, but only use a path and once it has created and stored it then call it back.
Baj.
-
Nov 23rd, 2021, 06:16 AM
#13
Re: Type Text Box In Form1 and Copied It to Form 2, Then Next Run Only Form 2 is App
Since the startup form isn't shown until after the Form_Load event is exited, I don't know why you couldn't just look for the existence of the save file, and if it exists, read it in and populate the Textbox on Form2 and do a Form2.Show and a Me.Hide as the last thing in the Form_Load event.
Code:
Private Sub Form_Load()
'if save file exists then
Form2.Text1.Text = "Assume I've read saved data in."
Form2.Show
Me.Hide
'end if
End Sub
If the file doesn't exist, then you will just display Form1 naturally.
"Anyone can do any amount of work, provided it isn't the work he is supposed to be doing at that moment" Robert Benchley, 1930
-
Nov 23rd, 2021, 08:25 AM
#14
Thread Starter
Lively Member
Re: Type Text Box In Form1 and Copied It to Form 2, Then Next Run Only Form 2 is App
Originally Posted by passel
Since the startup form isn't shown until after the Form_Load event is exited, I don't know why you couldn't just look for the existence of the save file, and if it exists, read it in and populate the Textbox on Form2 and do a Form2.Show and a Me.Hide as the last thing in the Form_Load event.
Code:
Private Sub Form_Load()
'if save file exists then
Form2.Text1.Text = "Assume I've read saved data in."
Form2.Show
Me.Hide
'end if
End Sub
If the file doesn't exist, then you will just display Form1 naturally.
passel,
Firstly, thank you for trying to explain to me and try to solve my problem, let me try to use your method.
Anyway I have solved my problem, I just refer to all information from members here.
Please see my video, on my video first I run my StartUp Form then once is create a path and text file then copied it by using a keypress on text box, this will automatically to filled it, once it filled to text box then execute by toggle a button.
But to save for the next run to keep the text box in Main Form, I still have not added it.
I say thank you so much to the members here, who have given me some ideas and guidance.
So.., my problem is solved.
Baj.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|