CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 4 1234 LastLast
Results 1 to 15 of 55
  1. #1
    Join Date
    Apr 2006
    Location
    Kolkata, India
    Posts
    278

    Exclamation How to show a form thru for next loop

    I have a form where some textboxes are there.
    Ho do I use for next loop to show that form for that number of times to take data.
    Please help

    Rahul

  2. #2
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: How to show a form thru for next loop

    You don't use a for next loop
    You show the form modal so it would not return until closed, and put either an OK button on that form to close it.
    Or you put some checking code in the change events of the text fields to determine when you can close the form.
    Code:
    InputForm.Show vbModal
    'in OK button
    Private Sub btnOK_Click()
      Me.Hide
    End Sub

  3. #3
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    4,538

    Re: How to show a form thru for next loop

    Hmm as much as I can see dsrahul is banned in this forum, isn't he
    Jonny Poet

    To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
    Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
    If anyone felt he has got help, show it in rating the post.
    Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
    My latest articles :
    Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7

  4. #4
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: How to show a form thru for next loop

    Is he?
    But he is here, though?
    How come he was banned in the first place?

  5. #5
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    4,538

    Re: How to show a form thru for next loop

    Quote Originally Posted by WoF View Post
    Is he?
    But he is here, though?
    How come he was banned in the first place?
    Its Ok Hannes informed me, he has got a chance for a second try
    Jonny Poet

    To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
    Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
    If anyone felt he has got help, show it in rating the post.
    Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
    My latest articles :
    Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7

  6. #6
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: How to show a form thru for next loop

    Right. Then I hope the hint will help.

  7. #7
    Join Date
    Apr 2006
    Location
    Kolkata, India
    Posts
    278

    Red face Re: How to show a form thru for next loop

    Dear Wof & Pop(JhonnyPoet),

    It was really nice to find & know that atleast I have 2 well wisher & friend.
    For no reason of mine ,I was banned.I was notified ,Reason for banning:-None Specified".
    I was not warned ,nor I was given any hint.
    I just PM'd Some of my enlisted buddies.
    Hannes is a good buddy of mine.
    I dunno who kicked my a** out of the forum.
    Anyway pals ,
    The Thread is still not resolved.
    Actually Waht I need is.
    The user enters two numbers i;e
    From 2012 : To 2020 (Whatever)
    the prog will subtract 2012-2020 which results in : 8
    The prog will now 1)open a form
    2) enter data
    3)Add it to the database(.MDB)
    4.) show the form again with all the textboxes cleared.
    This will be repeated for 8 times
    when the loop meets the number 8 the form dissappears.
    Please help.

    P.S ,I swear In future I will never PM any friend ever.

  8. #8
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    4,538

    Re: How to show a form thru for next loop

    Quote Originally Posted by dsrahul View Post

    Hannes is a good buddy of mine.
    He is one of the best and most helpful I personally know.
    To your program:
    The user enters two numbers i;e
    Where does he enter this ?
    From 2012 : To 2020 (Whatever)
    the prog will subtract 2012-2020 which results in : 8
    The prog will now 1)open a form
    Why this is opened and closed all the time. Why are the data added one by one to the database ?
    The standard way would be to have something like a form which has two sections One section where you enter the data that needs to be calculated the other section contains all that what is needed on your form which you designed to be always opened and closed.
    This way all the form is permanently to be seen and after you click to a button the data are stored and that part you normally would close is simple cleaned ( Textboxes empty ) For deviding one form into different sections use grouping by use of frames. Looks nice and you can ahve names for each group
    Jonny Poet

    To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
    Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
    If anyone felt he has got help, show it in rating the post.
    Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
    My latest articles :
    Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7

  9. #9
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: How to show a form thru for next loop

    Yes, this sums it up quite well.
    If you want to have a seperate form for the input of data records, you can do the same as JonnyPoet suggested. You have all the input fields and an OK button.
    Clicking the OK button writes the record to the database and erases all input fields.
    If you want it can also increment a counter and after n counts close the form.

    As far as I understand, the first operation is an input of record numbers or so which are subtracted to determine the number of new records to be produced.
    I would personally do like Jonny, putting these two input fields on the same form. Together with another button.
    You enter 2012 and 2020 and click the button. This will enable all input fields and allow as many records to be produced as B-A results in. The two input fields for the numbers can be disabled until all records have been produced.

  10. #10
    Join Date
    Apr 2006
    Location
    Kolkata, India
    Posts
    278

    Question Re: How to show a form thru for next loop

    Dearest POP & WoF,

    Thank you for your output in this regards.
    I would like to say That , Pop's Idea will work miracles for me regarding Appearance of the Form.
    As per Wof's Idea he has almost hit the bulls eye.
    Let me explain:-
    A Single customer has 20 samples to be tested.
    For Ex:=
    Name Sample code Iron Calculation SIO2 Al2O3 P S
    ------- ---------------- -------------------- ------ ------- -- ---
    ABC 2012 3.44 .064 3 1.2 0.02
    ^ ^ ^ Will change ^ will Change ..................
    Will be same Will change
    This will be the record structure.
    Now If I keep the name field as it is & enter the corresponding values of Fe,SIO2,Al2O3,P,S but
    Only Sample code is to be changed.
    That is why I have created a form which is called from another form where you enter how many samples or FROM sample number TO sample number.
    I am able to enter data into the Database but I need it to work this way.
    It is completing the loop first for I = 2102 to 2020
    then the data form appearing !!!
    Data is entering into database but for the first time it's run.
    The other data is not being entered.
    I tried WoF's Idea but somehow I am getting lost.
    There is an error regarding Modal
    This much info I can give you now.
    Tell me what I am missing.
    Thanks both of you once gain
    Rahul

    P.S the client says " If the form vanishes after each entry & then reappears again it would be convenient for him , if a label shows how many samples he had completed."

  11. #11
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: How to show a form thru for next loop

    The form needs not to vanish at all during the data entry.
    As you said, a label could show the number entries done.

    If the second form is shown vbModal it will stay in the foreground until closed (unloaded).
    Still, if you store your entries in a public array or collection, you can read these values from the unloaded form, or store them in public variables in a module. So you can do the writing to the database after all entries have been done.

    As for the error it would be good to see some lines of code around where the error occurs.

  12. #12
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    4,538

    Re: How to show a form thru for next loop

    Quote Originally Posted by WoF View Post
    As for the error it would be good to see some lines of code around where the error occurs.
    Yep or maybe if it is a small project simple zip it and post it, but dont forget to have a small database added with some dummy entries in that case.
    ----- edited ----
    I have read and reread your description but maybe a language barrier, I cannot get behind the ides why it is needed to have forms shown and hiddne again. Does the form you open and close be different each time ?
    If you have a bunch of data wh not using a datagrid ?
    I'm showing what I'm talking about using your figures you gave as an example so you know what is to be done where.
    The next button is the same as you would open your second form. It cleans the Form Section of old data or if needed fills new data there to be edited.
    Or you may use the next button for reading the next record in the database.
    The idea behind is: its not so good to have to much motion on the screen if not really absolutly necessary.
    Attached Images Attached Images  
    Last edited by JonnyPoet; August 11th, 2009 at 06:50 PM.
    Jonny Poet

    To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
    Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
    If anyone felt he has got help, show it in rating the post.
    Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
    My latest articles :
    Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7

  13. #13
    Join Date
    Apr 2006
    Location
    Kolkata, India
    Posts
    278

    Arrow Re: How to show a form thru for next loop

    Ok Pop,
    Thank you for your effort.
    This is the project which I am working on.
    There are three forms , (Sorry Pop ,I immediately zipped my project & send it to you.
    Hence I did not have time to try out your Form Design.

    In the 1st form there is a long green button , which you have to click
    then formcust appears where you enter record number (it maybe anything)
    Then Labcode number, after completeing all text boxes click accept.
    Then irnor.frm appears to intake your data for that particular labcode number.Press OK.
    Keeping customer data (name address etc same ) the other required entries will be changed then again irnor.frm appears to intake data for the next labcode number. Press Ok and it repeats until the loop finishes.
    Just see what modifications required .
    Thank you once again,
    Rahul
    Attached Files Attached Files

  14. #14
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    4,538

    Re: How to show a form thru for next loop

    Ok I have done a look on your project. So the form is a subform of another Form (frmcust ) which also has lots of Textboxes and all that. OK I can see your viewpoint now.

    But there are some main points you have so this will run into troubles
    a) You have never used Option explicit !
    So you can obviously never see if you have variables which are undefined like in Mainform
    Code:
    Private Sub Command3_Click()
    For i = clcn To clcm
    irnor.Show
    Next i
    End Sub
    I cannot find clcn nor clcm anywhere else in your project so this cannot run
    Additional in Form irnor you write
    Code:
    irnor.Label43.Caption = cnt
    irnor.abbc = ""
    irnor.abbr = ""
    irnor.abcal = ""
    irnor.abed = ""
    ....
    What are yoe refering to ? To the form itself ? Simple use
    Code:
    Me.Label43.Caption
    Me. ...
    Your program is a bit hard to read as 'abbc' and all this are Textboxes while 'clcn' maybe is a variable maybe not.
    Its a good custom to have Textboxes beginning with something like 'Txt' So your Textbox then would be 'TxtAbbc'
    Thngs like that would it make much easier for you and others to service the program in the future.

    We all grow older and when you just would have written 1000.000 lines of code you will know what I'm talking about that we all forget what we have created some years ago. Having Talking names and fixed rules which allow us to see on one short shot what a name is
    ( a Variant, a Textbox, an integer , a Label, ... ) will make life for you much easier. But this, as well as using Option explicit is only a general hint

    The following code
    Code:
        'Call Form_Resize
       frmcust.MSHFlexGrid1.ColWidth(0) = 40
       frmcust.MSHFlexGrid1.ColWidth(1) = 800
    ...
    Readresses to the calling form, which would be basically Ok if you only open that form with frmcust as its owner, but as we see , you also open that form from MainForm Command3 and this way you will get a heavy Crash !!

    the next main problem you have is
    You are opening the form irnor as wanted from frmcust and then pressing Command1 on that form you are simple hiding it and disabling a lot of frmcust
    Code:
    frmcust.cusrpn.Enabled = False
    frmcust.cusadd.Enabled = flase
    frmcust.custel.Enabled = False
    frmcust.cusna.Enabled = False
    ...
    When you are finished with that cycle how will you ever enable this again.
    And why hiding ? why not simple close and open it as usual simple call unload(me)
    The solution for the last problem is easy. Disable that directly in frmcust before you are beginning to loop
    and enable it when your cycle, looping through all that irnor.Show() cycles is finished. So you have disable before loop starts and enable after loop is done

    BTW you havn't added the needed Icons so the project has some errors at loading, but I can live with that
    Last edited by JonnyPoet; August 12th, 2009 at 04:36 AM.
    Jonny Poet

    To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
    Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
    If anyone felt he has got help, show it in rating the post.
    Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
    My latest articles :
    Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7

  15. #15
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: How to show a form thru for next loop

    Good lesson Jonny.
    I'm sorry I can't open this rar archive. PowerArchiver seems not to like it.
    Can you please use a normal zip archive?

Page 1 of 4 1234 LastLast

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

Featured