Multi Forms and List Boxes
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Multi Forms and List Boxes

  1. #1
    Join Date
    Apr 2011
    Posts
    2

    Multi Forms and List Boxes

    Ok, Im having trouble passing a value from one form back to another using a listbox... The user clicks a button in the main form to bring up an instance of another form (form2.show). In that form, the user then then selects a number 1-5 and then presses done:

    Code:
    Private Sub frmPlayer_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim x As Integer
            If lboNumber.Items.Count = 0 Then 'list box is empty
                For x = 1 To 5
                    lboNumber.Items.Add(x.ToString)
                Next
            End If
    
        End Sub
    How do I pass that value back to the main form as a value when the user clicks done?

  2. #2
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,960

    Re: Multi Forms and List Boxes

    Create a PUBLIC property, and you can call it from a different form. Not DIM'd
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,090

    Re: Multi Forms and List Boxes

    Simple, I'd set the Done button ( on the second form ) 's DialogResult property to OK, then show Form 2 with ShowDialog, as in :

    Code:
    Dim f2 As New Form2
            If f2.ShowDialog() = Windows.Forms.DialogResult.OK Then
    ....

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center