Results 1 to 25 of 25

Thread: How to display the results in a pop up separate form?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2014
    Posts
    26

    How to display the results in a pop up separate form?

    My professor requires me to display the results in a different pop up form.
    I have search, but dont know the keywords, any advice would be appreciated.
    Name:  1.jpg
Views: 792
Size:  25.7 KB
    Last edited by johnnxiv; May 27th, 2014 at 10:58 PM.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: How to display the results in a separate form?

    I'm not quite sure what sort of magic solution you expect to find. You create a form, you pass it the required data, you display it. Have you worked with more than one form before? Do you know how to display a form?

  3. #3

    Thread Starter
    Junior Member
    Join Date
    May 2014
    Posts
    26

    Re: How to display the results in a separate form?

    I think you miss my question, I know how to display the results in the listbox on the same form.

    I don't know how to display the results in a separate form, that is my question

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: How to display the results in a pop up separate form?

    Um, no I did not miss your question. Why do you think I asked:
    Have you worked with more than one form before?
    Displaying the data in a separate form is exactly the same as displaying it in the same form. A form is a form. Once you have created the new form you pass the data from the first form to the second, populate the controls just as you would in the same form and then display the second form. So, what part are you having trouble with? I ask a second time, do you know how to display a form, i.e. a separate for to the one that you already have open?

  5. #5
    Member robie's Avatar
    Join Date
    May 2014
    Posts
    34

    Re: How to display the results in a separate form?

    Quote Originally Posted by johnnxiv View Post
    I think you miss my question, I know how to display the results in the listbox on the same form.

    I don't know how to display the results in a separate form, that is my question

    u said u can display results in listbox on the same form so the problem is u cant do it on another form??


    example i have 2 forms, name form1 and form2

    so

    fom1.listbox to display result at form1
    form2.listbox to display result at form2


    i dont know if these helps u..

  6. #6

    Thread Starter
    Junior Member
    Join Date
    May 2014
    Posts
    26

    Re: How to display the results in a pop up separate form?

    Sorry for my stupidity, I tried and still didn't work out.
    My first form is HW3.Vb, my output form is Output.vb

    My calculation codes are
    lstTotals.Items.Add(String.Format(fmtStr, "", "", "Value at", "Amount Deprec", "Total Depreciation"))
    lstTotals.Items.Add(String.Format(fmtStr, "", "Year", "Beg of Yr", "During Year", "to End of Year"))

    For i As Integer = 1 To YearDepriciate
    amountDepr = DepreciatePerYear
    If i = YearDepriciate Then
    amountDepr = Cost
    End If
    TotalDepreciate += amountDepr
    lstTotals.Items.Add(String.Format(fmtStr, "", YearPurchased, Cost.ToString("C"), amountDepr.ToString("C"), TotalDepreciate.ToString("C")))
    Cost -= amountDepr
    YearPurchased += 1
    Next

    Can any1 give me an example code?

  7. #7
    Member robie's Avatar
    Join Date
    May 2014
    Posts
    34

    Re: How to display the results in a pop up separate form?

    Quote Originally Posted by johnnxiv View Post
    Sorry for my stupidity, I tried and still didn't work out.
    My first form is HW3.Vb, my output form is Output.vb

    My calculation codes are
    lstTotals.Items.Add(String.Format(fmtStr, "", "", "Value at", "Amount Deprec", "Total Depreciation"))
    lstTotals.Items.Add(String.Format(fmtStr, "", "Year", "Beg of Yr", "During Year", "to End of Year"))

    For i As Integer = 1 To YearDepriciate
    amountDepr = DepreciatePerYear
    If i = YearDepriciate Then
    amountDepr = Cost
    End If
    TotalDepreciate += amountDepr
    lstTotals.Items.Add(String.Format(fmtStr, "", YearPurchased, Cost.ToString("C"), amountDepr.ToString("C"), TotalDepreciate.ToString("C")))
    Cost -= amountDepr
    YearPurchased += 1
    Next

    Can any1 give me an example code?

    what do u want is displaying ur result at outform right? base on ur code above it has calculations but where did you pass the result value of that? in a textbox? listbox? label?

    JMC]Displaying the data in a separate form is exactly the same as displaying it in the same form said by JMC
    jmc is right it's so simple exactly the same as displaying it in the same form

    if u will able to display result a HW3 form then it's the same as displaying it to other form by adding ur form OUTPUT,

    example: HW3 form then
    ur calculation code then pass to textbox1.text

    the if you want to display it to OUTPUT form then
    OUTPUT.mytextbox.text = HW3.textbox1.text
    Last edited by robie; May 28th, 2014 at 09:08 PM. Reason: edit

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: How to display the results in a pop up separate form?

    You aren't referring to that Output form anywhere in that code so I'm not sure how you expect anything to be output. I've asked you the same question twice now and you have refused to answer it. If you're not prepared to answer my questions then why would I write your code for you?

  9. #9

    Thread Starter
    Junior Member
    Join Date
    May 2014
    Posts
    26

    Re: How to display the results in a pop up separate form?

    I have never work with more than one form before. Im a newbie at Vb.

    Im trying to direct the codes to display in a Listbox on the Output form.

  10. #10
    Member robie's Avatar
    Join Date
    May 2014
    Posts
    34

    Re: How to display the results in a pop up separate form?

    Quote Originally Posted by johnnxiv View Post
    I have never work with more than one form before. Im a newbie at Vb.

    Im trying to direct the codes to display in a Listbox on the Output form.

    so u mean "listbox" is the one getting the result right?

    get some logic to these code:

    Form2.Label1.Text = Form1.TextBox1.Text

    it pass the value of textbox1 to label1.text.

  11. #11

    Thread Starter
    Junior Member
    Join Date
    May 2014
    Posts
    26

    Re: How to display the results in a pop up separate form?

    I finally figured it out by online websites, Thanks but when ur explanation is too complicated?
    Last edited by johnnxiv; May 30th, 2014 at 01:39 AM.

  12. #12
    Member robie's Avatar
    Join Date
    May 2014
    Posts
    34

    Re: How to display the results in a pop up separate form?

    good for you to resolve your problem..



    i dont see anything complicated in my explanation even a beginner in vb can understand that -_-
    Last edited by robie; May 30th, 2014 at 11:22 AM. Reason: edit

  13. #13

    Thread Starter
    Junior Member
    Join Date
    May 2014
    Posts
    26

    Re: How to display the results in a pop up separate form?

    Sorry I didnt see this in

    Private Sub btnbtnDouble_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnbtnDouble.Click

    Dim frmHW3 As New frmOutput
    frmOutput.Show()

    or a similar example to that,

  14. #14

    Thread Starter
    Junior Member
    Join Date
    May 2014
    Posts
    26

    Re: How to display the results in a pop up separate form?

    I'm trying to format my outputs to be nice and neat like this
    http://www.vbforums.com/attachment.p...1&d=1401238326

    but my outputs are ugly, what is wrong with my codes?
    Name:  1.jpg
Views: 450
Size:  36.0 KB

    Dim fmtStr As String = "{0,2} {1, -10} {2, 10:N2} {3, 22:N2} {4, 25:N2}"

    frmOutput.lstOutput.Items.Add(String.Format(fmtStr, "", intYearPurchased, dblCost.ToString("C"), dblAmountDepr.ToString("C"), dblTotalDepreciate.ToString("C")))

  15. #15
    Member robie's Avatar
    Join Date
    May 2014
    Posts
    34

    Re: How to display the results in a pop up separate form?

    question: your using multiline textbox or richtextbox in your output form?
    Last edited by robie; May 31st, 2014 at 06:15 PM. Reason: edit

  16. #16

    Thread Starter
    Junior Member
    Join Date
    May 2014
    Posts
    26

    Re: How to display the results in a pop up separate form?

    Quote Originally Posted by robie View Post
    question: your using multiline textbox or richtextbox in your output form?
    Im using list box, you can see lstOutput.Items.Add

  17. #17
    Member robie's Avatar
    Join Date
    May 2014
    Posts
    34

    Re: How to display the results in a pop up separate form?

    ok then try these,
    Code:
     listbox.Items.Add("sample column1" & ControlChars.Tab & "sample column2" _
           & ControlChars.Tab & "sample column3" & ControlChars.Tab & _
            "sample column4" & ControlChars.Tab & "sample column5")

    it set the column header of lisbox w/ 5 spaces each(tab)..

    try the code if these align the items on your listbox

  18. #18

    Thread Starter
    Junior Member
    Join Date
    May 2014
    Posts
    26

    Re: How to display the results in a pop up separate form?

    Thank for your help, but it didn't work because I followed a code I found online
    Its all about the number "{0,2} {1, -10} {2, 10:N2} {3, 22:N2} {4, 25:N2}", I just dont understand them thats why

    Dim fmtStr As String = "{0,2} {1, -10} {2, 10:N2} {3, 22:N2} {4, 25:N2}"

    frmOutput.lstOutput.Items.Add(String.Format(fmtStr, "", intYearPurchased, dblCost.ToString("C"), dblAmountDepr.ToString("C"), dblTotalDepreciate.ToString("C")))

  19. #19
    Member robie's Avatar
    Join Date
    May 2014
    Posts
    34

    Re: How to display the results in a pop up separate form?

    try to make a new listbox and paste the code i post and you can see the output, its just a sample code to align each text..


    Dim fmtStr As String = "{0,2} {1, -10} {2, 10:N2} {3, 22:N2} {4, 25:N2}"
    me neither cant understand what these for, maybe someone would know

  20. #20

    Thread Starter
    Junior Member
    Join Date
    May 2014
    Posts
    26

    Re: How to display the results in a pop up separate form?


  21. #21
    Member robie's Avatar
    Join Date
    May 2014
    Posts
    34

    Re: How to display the results in a pop up separate form?

    im afraid the question you are referring for is outside of the topic..

    basically you have some mistakes in your calculation method..

    well your output form is nice and align now.. that's good

  22. #22

    Thread Starter
    Junior Member
    Join Date
    May 2014
    Posts
    26

    Re: How to display the results in a pop up separate form?

    sadly the output is still not nice and align, the double decline out put look ugly like above.

    U have any idea why my variable keep adding up?

  23. #23
    Member robie's Avatar
    Join Date
    May 2014
    Posts
    34

    Re: How to display the results in a pop up separate form?

    base on your picture, all i can see that add is the last column which is the Total depreciation to end of year? is that what u talking about?

    in that case try to clear the value of that field, your restart button try make commands into it that clear or reset all your declare variable to 0 so that every time you restart it wont add the previous calculation.

    if your having a hardtime in aligning the best way is to use listview or datagridview not listbox

  24. #24

    Thread Starter
    Junior Member
    Join Date
    May 2014
    Posts
    26

    Re: How to display the results in a pop up separate form?

    What is the trick to force focus to only 1 window at a time? Let say my Results window poped up, how can I block user from using the bottom window? This is another way to prevent the user from multiclick the calculate buttom
    Last edited by johnnxiv; Jun 2nd, 2014 at 11:37 PM.

  25. #25
    Member robie's Avatar
    Join Date
    May 2014
    Posts
    34

    Re: How to display the results in a pop up separate form?

    what do u mean by bottom window? have a print screen so that it would easy to understand..

    you u only want one form at a time you should hide the form you want and show the form you only want. that's basic

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