17436.html
来自「以电子书的形式收集了VB一些常见问题解决方法,可以很方便的查找自己需要解决的问题」· HTML 代码 · 共 27 行
HTML
27 行
<html> <head> <title>我用如下的 code, but run time 时会有 语法错误 at : Public Function GetaLine(Text1 As TextBox, ByVal ntx As Long) As String</title> </head> <body bgcolor="#FFFFFF" vlink="#808080"> <center> <h1>我用如下的 code, but run time 时会有 语法错误 at : Public Function GetaLine(Text1 As TextBox, ByVal ntx As Long) As String</h1> </center><hr size=7 width=75%><hr size=7 width=75%><p>Posted by Albert on August 18, 1999 at 10:53:43:<p>In Reply to: <a href="17424.html">请问 textbox (MultiLine) 有没有方法可以 get 某一行的 data ? Thanks much !!</a> posted by Albert Chiu on August 17, 1999 at 20:50:28:<p>Private Sub Command1_Click()<br>Dim str5 As String<br>Dim LineCnt As Long<br> <br>LineCnt = TextBoxLineCnt(Text1)<br>str5 = GetaLine(Text1, 1) '取得第二行的字串,以0为基底<p>Debug.Print str5<br>End Sub<p>' .BAS<br>Option Explicit<br>Const EM_GETLINE = &HC4<br>Public Const EM_GETLINECOUNT = &HBA<br>Declare Function SendMessage Lib "user32" Alias "SendMessageA" _<br> (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _<br> lParam As Any) As Long<br> Public Function GetaLine(Text1 As TextBox, ByVal ntx As Long) As String<br> Dim str5(255) As Byte '如果您的字串 > 255 byte请自行增加该Byte Array<br> Dim str6 As String, i As Long<br> <br> str5(0) = 255 '字串的前两个Byte存该字串的最大长度 str5(0) = 255<br> i = SendMessage(Text1.hwnd, EM_GETLINE, ntx, str5(0))<br> If i = 0 Then<br> GetaLine = ""<br> Else<br> str6 = StrConv(str5, vbUnicode)<br> GetaLine = Left(str6, InStr(1, str6, Chr(0)) - 1)<br> End If<br>End Function<p><br>Option Explicit<br>Public Function TextBoxLineCnt(ctl As TextBox) As Long<br>TextBoxLineCnt = SendMessage(ctl.hwnd, EM_GETLINECOUNT, 0, 0)<br>End Function<p><br><br><hr size=7 width=75%><p><a name="followups">Follow Ups:</a><br><ul><!--insert: 17436--><!--top: 17483--><li><a href="17483.html">我的程式码没有错</a> <b> cww</b> <i>08:27:12 8/19/99</i>(<!--responses: 17483-->0)<ul><!--insert: 17483--></ul><!--end: 17483--></ul><!--end: 17436--><br><hr size=7 width=75%><p></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?