VB 如何获取外部程序文本框内容
1个回答
2013-11-01
展开全部
'获取控件的内容
Option Explicit
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_GETTEXT = &HD
Private Const WM_GETTEXTLENGTH = &HEPublic Function GetTextString(ByVal lyHwnd As Long) As String
Dim GetS As String
Dim SLen As Long
SLen = SendMessage(lyHwnd, WM_GETTEXTLENGTH, 0, 0)
If SLen = 0 Then Exit Function
SLen = SLen + 1
GetS = Space(SLen)
SLen = SendMessage(lyHwnd, WM_GETTEXT, SLen, ByVal GetS)
GetTextString = Left(GetS, SLen)
End Function 控件的句柄你应该能获取到,所以不说了
Option Explicit
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_GETTEXT = &HD
Private Const WM_GETTEXTLENGTH = &HEPublic Function GetTextString(ByVal lyHwnd As Long) As String
Dim GetS As String
Dim SLen As Long
SLen = SendMessage(lyHwnd, WM_GETTEXTLENGTH, 0, 0)
If SLen = 0 Then Exit Function
SLen = SLen + 1
GetS = Space(SLen)
SLen = SendMessage(lyHwnd, WM_GETTEXT, SLen, ByVal GetS)
GetTextString = Left(GetS, SLen)
End Function 控件的句柄你应该能获取到,所以不说了
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询