"Sender" Error

micro

Well-Known Member
Licensed User
Longtime User
Hi,
why this code producest an InvalidCastException Error?

B4X:
Sub modificaarctxt_KeyPress (key)
   If key = Chr(13) Then
      modifica_archivio
      Sender.IgnoreKey
   End If
End Sub

This works perfectly

B4X:
Sub modificaarctxt_KeyPress (key)
   If key = Chr(13) Then
      modifica_archivio
      modificaarctxt.IgnoreKey
   End If
End Sub

No problem on the Desktop. (vers. 6.90 Basic4ppc)
 

agraham

Expert
Licensed User
Longtime User
Sender returns a String, not a control reference which is what is neeeded to invoke a method on.

I haven't time to test it but assuming v6.90 TextBox(FullNameSender).IgnoreKey should work as it turns the string into a reference to the control.
 
Top