以下使用sendmessage的vb代码如何修改成vb.net的代码?请指教,谢谢。

我刚从vb环境转到vb.net,很不适应。OptionExplicitPrivateDeclareFunctionSendMessageLib"user32"Alias"... 我刚从vb环境转到vb.net,很不适应。
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 Declare Function GetKeyNameText Lib "user32" Alias "GetKeyNameTextA" (ByVal lParam As Long, ByVal lpBuffer As String, ByVal nSize As Long) As Long

Private Const WM_GETTEXT = &HD&
Private Const WM_GETTEXTLENGTH = &HE&
'Dim a As Long
Dim GetIParam As Long
Dim GetString As String * 255
Private Sub Command1_Click()
Text1.Text = Command1.hwnd
'a = SendMessage(CLng(Text1.Text), WM_GETTEXTLENGTH, 0, 0)
SendMessage CLng(Text1.Text), WM_GETTEXT, 255, ByVal GetString '255是缓冲区的长度
'GetKeyNameText GetIParam, GetString, Len(GetString)
MsgBox GetString
End Sub
展开
 我来答
Seneal
2013-01-11 · 超过22用户采纳过TA的回答
知道答主
回答量:46
采纳率:0%
帮助的人:63万
展开全部
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As String) As Integer
'Private Declare Function GetKeyNameText Lib "user32" Alias "GetKeyNameTextA" (ByVal lParam As Long, ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Const WM_GETTEXT As Integer = &HD
Private Const WM_GETTEXTLENGTH As Integer = &HE
'Dim a As Long
Dim GetIParam As Integer
Dim GetString As String
Private Sub Command1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command1.Click
GetString = Space(255)
'a = SendMessage(CLng(Text1.Text), WM_GETTEXTLENGTH, 0, 0)
Text1.Text = Command1.Handle.ToInt32
SendMessage(CInt(Text1.Text), WM_GETTEXT, 255, GetString) '255是缓冲区的长度
'GetKeyNameText GetIParam, GetString, Len(GetString)
MsgBox(GetString)
End Sub
百度网友bdb9803
2013-01-11 · TA获得超过1.1万个赞
知道大有可为答主
回答量:1.1万
采纳率:53%
帮助的人:1亿
展开全部
这样机械的转换不是编程的好方法,实际上VB.NET内部函数已经支持大量的API,很多情况下无需引用API了
追问
能不能推荐本适合我的vb.net的书呢?vb6我挺熟的,谢谢你了,感觉你的话已经让我受益了。
追答
书我也没看过,我的做法是,编一个比较复杂的vb.net软件,然后遇到问题就上网搜,搜不到就问百度知道,完成以后基本就熟了
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式