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 EM_GETLINE = &HC4Private Sub Command1_Click()
Dim str1(250) As Byte'这里为什么要定义成数组
Dim str3 As String
Dim str2 As String * 250
str1(0) = 250'这里赋值是怎么回事?
Dim i As Long
 SendMessage Text1.hwnd, EM_GETLINE, 1, str1(0)
str2 = StrConv(str1, vbUnicode)
str3 = Left(str2, InStr(1, str2, Chr(0)) - 1)
MsgBox (str3)
End Sub

解决方案 »

  1.   

    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 EM_GETLINE = &HC4 Private Sub Command1_Click() 
    Dim str1(250) As Byte'这里为什么要定义成数组 因为这个参数要作为指针传送,声明为数组比较方便(自然是指针)
    Dim str3 As String 
    Dim str2 As String * 250 
    str1(0) = 250'这里赋值是怎么回事? (这里给出行的最大长度)
    Dim i As Long 
     SendMessage Text1.hwnd, EM_GETLINE, 1, str1(0) 
    str2 = StrConv(str1, vbUnicode) 
    str3 = Left(str2, InStr(1, str2, Chr(0)) - 1) 
    MsgBox (str3) 
    End Sub