How can I achieve this?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Astralogic
    New Member
    • Dec 2019
    • 1

    How can I achieve this?

    Hi, I've been trying to figure this out for a while now and I'm getting nowhere even though people tell me it's not only possible but easy.

    I'm trying to self-learn VB so this is a basic issue.

    Here is what I want to do, I want a textbox on form1 and a listbox on form2. I want typing in the textbox on form1 to populate the listbox on form 2.

    But I also want a connection going the other way, when I click an item in the listbox on form 2, I want the text to appear in the textbox on form 1.

    Could someone help me figure this out please?
    Thanks
  • SioSio
    Contributor
    • Dec 2019
    • 272

    #2
    Since the condition that input to Textbox1 of Form1 is confirmed is necessary, press Button1 when the input is completed.
    Declare Listbox1 of Form2 as Public.

    Code:
    Form1
    Private button1 As System.Windows.Forms.Button
    Private textBox1 As System.Windows.Forms.TextBox
    :
    :
    Sub Button1Click(sender As Object, e As EventArgs)
    	My.Forms.Form2.listBox1.Items.add(textBox1.text)
    End Sub
    
    
    Form2
    Public listBox1 As System.Windows.Forms.ListBox
    Last edited by gits; Dec 17 '19, 09:16 AM. Reason: use code tags!

    Comment

    Working...