I wants send value to text box of ChildForm From diagbox
Error : System.MissingMemberException: 'No default member found for type 'TextBox'.'
My code:
Private Sub SimpleButton1_Click(sender As Object, e As EventArgs) Handles SimpleButton1.Click
For Each frm As Form In Application.OpenForms
If frm.IsMdiChild Then
If frm.Name = "FRM_3_213_1_BBT_TIENICH_CARD_YAMAHA_INPUT" Then
CallByName(frm, "TextBox1", CallType.Set, "Text", "AAAAAAA")
End If
End If
Next
End Sub
Can someone please help me resolve this issue? Thanks is advance.
CodePudding user response:
This should work
Private Sub SimpleButton1_Click(sender As Object, e As EventArgs) Handles SimpleButton1.Click
For Each frm As Form In Application.OpenForms
If frm.IsMdiChild Then
If frm.Name = "FRM_3_213_1_BBT_TIENICH_CARD_YAMAHA_INPUT" Then
Dim t As TextBox
t = CType(frm.Controls("TextBox1"), TextBox)
t.Text = "AAAAAAA"
End If
End If
Next
End Sub
The reason your code does not work is that a generic Form object does not have "TextBox1" property. You can make CallByName work if you cast frm object into a specific form type that has the textbox control.
You can also try
CallByName(frm.Controls("TextBox1"), "Text", CallType.Set, "AAAAAAA")