none
Unable to Transfer Text Value from One Form to Other Active & Open Form RRS feed

  • Question

  • 

    Here First Form is opened i.e

    Try
    
                If DGV_Return.SelectedRows.Count > 0 Then
                    Dim bcodePrev As Double
                    Dim bcodeRet As Double
                    Dim QtyPrev As Integer
                    Dim QtyRet As Integer
                    Dim SlNoPrev As Integer
                    Dim SlNoRet As Integer
                    Dim status As String
    
                    QtyPrev = Abs(Val(Me.Txt_InvQty.Text))
                    QtyRet = Val(Txt_QtyReturn.Text)
                    bcodePrev = Val(Txt_InvBarcode.Text)
                    bcodeRet = Val(Txt_BCodeReturn.Text)
                    SlNoPrev = Val(Txt_SlNoPvs.Text)
                    SlNoRet = Val(Txt_SlNoReturn.Text)
                    status = Txt_RetItemStatus.Text
    
                    If QtyPrev <> QtyRet Then
                        MsgBox("Quantity not matched or Item Returned of that invoice........")
                    ElseIf bcodePrev <> bcodeRet Then
                        MsgBox("barcode not matched........")
                    ElseIf status <> "" Then
                        MsgBox("Item allready returned........")
                        'ElseIf QtyPrev = QtyRet And bcodePrev = bcodeRet And PidPrev = PidRet And status = "" Then
                    ElseIf QtyPrev = QtyRet And bcodePrev = bcodeRet And status = "" Then
                        Dim id As Integer
                        Dim itemstatus As String
                        id = Txt_salesreturnid.Text
                        itemstatus = "Y"
                        Txt_RetItemStatus.Text = itemstatus
                        Me.Hide()
                        Frm_Transaction.DGV_InvoiceItem.Item(13, Frm_Transaction.DGV_InvoiceItem.CurrentRow.Index).Value = Me.Txt_RetInvID.Text
                        Frm_Transaction.Txt_RetItemStatus.Text = itemstatus
                        Frm_Transaction.Txt_SlNo.Text = SlNoRet
    
    
    
                    ElseIf QtyPrev = QtyRet And bcodePrev = bcodeRet And status <> "" Then
                        MessageBox.Show("Please check the invoice id/cash sale no.....")
                    End If
                Else
                    MsgBox("Kindly select the row first.....")
                End If
            Catch ex As Exception
                Call Error_Check()
            End Try
    First form is which is opened and active : (Frm_Transaction)

    Now from Form 2, i have to transfer some value to Form1. (Frm_Return_Exchange)

    My Code is as Follows:

    Try

                If DGV_Return.SelectedRows.Count > 0 Then
                    Dim bcodePrev As Double
                    Dim bcodeRet As Double
                    Dim QtyPrev As Integer
                    Dim QtyRet As Integer
                    Dim SlNoPrev As Integer
                    Dim SlNoRet As Integer
                    Dim status As String

                    QtyPrev = Abs(Val(Me.Txt_InvQty.Text))
                    QtyRet = Val(Txt_QtyReturn.Text)
                    bcodePrev = Val(Txt_InvBarcode.Text)
                    bcodeRet = Val(Txt_BCodeReturn.Text)
                    SlNoPrev = Val(Txt_SlNoPvs.Text)
                    SlNoRet = Val(Txt_SlNoReturn.Text)
                    status = Txt_RetItemStatus.Text

                    If QtyPrev <> QtyRet Then
                        MsgBox("Quantity not matched or Item Returned of that invoice........")
                    ElseIf bcodePrev <> bcodeRet Then
                        MsgBox("barcode not matched........")
                    ElseIf status <> "" Then
                        MsgBox("Item allready returned........")
                        'ElseIf QtyPrev = QtyRet And bcodePrev = bcodeRet And PidPrev = PidRet And status = "" Then
                    ElseIf QtyPrev = QtyRet And bcodePrev = bcodeRet And status = "" Then
                        Dim id As Integer
                        Dim itemstatus As String
                        id = Txt_salesreturnid.Text
                        itemstatus = "Y"
                        Txt_RetItemStatus.Text = itemstatus
                        Me.Hide()
                        Frm_Transaction.DGV_InvoiceItem.Item(13, Frm_Transaction.DGV_InvoiceItem.CurrentRow.Index).Value = Me.Txt_RetInvID.Text
                        Frm_Transaction.Txt_RetItemStatus.Text = itemstatus
                        Frm_Transaction.Txt_SlNo.Text = SlNoRet
                    ElseIf QtyPrev = QtyRet And bcodePrev = bcodeRet And status <> "" Then
                        MessageBox.Show("Please check the invoice id/cash sale no.....")
                    End If
                Else
                    MsgBox("Kindly select the row first.....")
                End If
            Catch ex As Exception
                Call Error_Check()
            End Try

    Please help to fix this issue....

    Thanks for your anticipation

    faizahmad_dnr@hotmail.com

    Friday, August 10, 2018 9:33 PM

All replies

  • Hi

    I have no idea what the code you posted is for.

    1. Where are these code blocks?

    2. What, exactly, are the 2 Form names?

    3. You mention a variable you want 'sent' to Form1 - but there is no sign of it!

    Here is some code that does work. Form1 and Form2 each with 3 TextBoxes and Form1 also has Button1.

    Form1 code

    ' Form2 with TextBox1, TextBox2,
    ' TextBox3 and Button1
    Option Strict On
    Option Explicit On
    Public Class Form1
      Dim nf2 As New Form2
      Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        nf2.Show()
      End Sub
      Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        TextBox1.Text = nf2.One
        TextBox2.Text = nf2.Two
        TextBox3.Text = nf2.Three
        ' Now, these TextBoxes contain
        ' the values from Form2
      End Sub
    End Class

    Form2 code

    ' Form2 with TextBox1, TextBox2
    ' and TextBox3
    Public Class Form2
      Property One As String = Nothing
      Property Two As String = Nothing
      Property Three As String = Nothing
      Private Sub TextBox_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
        One = TextBox1.Text
      End Sub
      Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged
        Two = TextBox2.Text
      End Sub
      Private Sub TextBox3_TextChanged(sender As Object, e As EventArgs) Handles TextBox3.TextChanged
        Three = TextBox3.Text
      End Sub
    End Class


    Regards Les, Livingston, Scotland

    Friday, August 10, 2018 10:06 PM