Pass item from a Listbox to a Label

0

I have a program that has a Listbox1 on Form1, and I want that when I press the Modify button, the form is closed and the Id item goes to a Label1 on Form2.

I tried using the Userform_Load but I do not know how to assign the selected row of Listbox1.

I have also intando the following

Private Sub UserForm_Initialize () Dim i As Integer 'I get the index that is selected i = HistoryTickets.lstTicketsProblems.SelectedIndex

'I pass the item value lblCorrelativoTk.Text = HistorialTickets.lstTicketsProblemas.Items (i) .Text

End Sub

and I get method error or can not find member data.

Waiting for your comments.

    
asked by Emir Salinas 27.12.2018 в 18:55
source

1 answer

0

Try doing the following: In form 2 declares a public variable, for example Public data As String

Then on the modify button of form 1 you put the following: form2.dato = tuListBox.Text form2.Show () Me.Hide ()

In form 2 in the load event, you put the following: tuLabel.Caption = data

    
answered by 27.12.2018 в 22:57