i have 2 form and 1 dialog... the problem is when i select form2 as startup form i'm not able to copy text from combobox1 on dialog1 to textbox1 which is on form1 ... if i select form1 as startup form its working fine... i 'm not getting whats the problem....
i have placed code with form design as following ...
plz help

Public Class Form2
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim fo As New Form1
        fo.Show()

    End Sub
End Class

'Code for form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim dialog As New Dialog1 dialog.Show() End Sub

'Code for dialog1 Imports System.Windows.Forms Public Class Dialog1 Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click Form1.TextBox1.Text = Me.ComboBox1.Text Me.DialogResult = System.Windows.Forms.DialogResult.OK Me.Close() End Sub Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click Me.DialogResult = System.Windows.Forms.DialogResult.Cancel Me.Close() End Sub End Class

Problem is in your code at Dim dialog As New Dialog1 and you are calling dialoge.show() this wrong you should call

dialog.Show()

i'm not able to copy text from combobox1 on dialog1 to textbox1 which is on form1

Hi Rajendra, you haven't said what happens when you try. Do you get an exception?

Looks like your dialog1 form has a problem:

Form1.TextBox1.Text = Me.ComboBox1.Text

Have you instantiated Form1? Do you get a null reference exception?
I think it would be easier to take that line out of your dialog form and use this in form2 button1 click :

Dim dialog As New Dialog1
        With dialog
            .ShowDialog()
            If .DialogResult = Windows.Forms.DialogResult.OK Then
                Me.TextBox1.Text = .ComboBox1.Text
            End If
        End With
This article has been dead for over six months. Start a new discussion instead.