Pass a string to a textbox

Hello All,
I have a small issue with passing a string to a textbox.. the senario is as follow:

Form1 is opened with textbox1 and button1

When pressing button1, form2 opens to allow searching in a database.

Results of form2 search are listed in listview1.

selecting the required reslt is by clicking the desired item in listview1.

Now.. I need to pass the result to textbox1 in form1 that is already opened.

How?

[428 byte] By [Fayed] at [2007-12-16]
# 1

Dim F2 as New Form2()

F2.ShowDialog

Textbox1.Text = F2.ListView1.SelectedItems(0).Text

TaDa at 2007-9-9 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 2
or u can try storing the result in a global variable, then retrieve from the global variable when u need it ...
jerrylhl at 2007-9-9 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 3
>or u can try storing the result in a global variable, then retrieve from the global >variable when u need it ...
>

Too mutch work to be done... will resolve to conflicts for public variables will increase rapidly

Thanks anyway Big Smile

Fayed at 2007-9-9 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 4
Posted In VB Languages forums;

Hi,
In your form1, you could create a method to set the text in your textbox:

Public Sub setText(newText as String)
text1.Text = newText
End Sub

Just call this function in the event of you listbox this way.

'Inside the click event of listview
Dim myForm As Form1 = DirectCast(Me.Owner, Form1)
myForm.setText(listview.Text <Or whatever the result is>)
' end snippet

BTW, in showing your form2, you must ust the form2.Show(this) method so that the owner would be set to form1...
cheers,
Paul June A. Domag

Fayed at 2007-9-9 > top of Msdn Tech,Visual Basic,Visual Basic General...