CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2011

    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:

    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
            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
    Fox Lake, IL

    Re: Multi Forms and List Boxes

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

    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
    Sunny South Africa

    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 :

    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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.