本例是Form中有一个按钮。
Public Class Form3
Private Declare Auto Function SendMessage Lib "user32" Alias "SendMessageW" (ByVal hwnd As Integer,ByVal wMsg As Integer,ByVal wParam As Integer,ByVal lParam As String) As Integer
Private Const EM_SETTEXT = &HC ' VB中&H表示16进制
'Private Const WM_GETTEXT = &HC
Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles Button1.Click
Dim hwnd As IntPtr = CType(Me.Handle,IntPtr)
'Sendmessage(目标控件句柄,自定义消息类型,参数个数,消息内容)
SendMessage(hwnd,EM_SETTEXT,"myTest")
End Sub
End Class