8154.html

来自「VB技巧问答10000例,是一个教程」· HTML 代码 · 共 23 行

HTML
23
字号
<html>
  <head>
    <title>Re: 请问:应如何将muliline 的Text 列印出来?</title>
  </head>
  <body bgcolor="#FFFFFF" vlink="#808080">
    <center>
      <h1>Re: 请问:应如何将muliline 的Text 列印出来?</h1>
    </center>
<hr size=7 width=75%>

<hr size=7 width=75%><p>
Posted by <a href="mailto:richard@mail.high-way.com.tw">richard</a> on December 09, 1998 at 09:50:44:<p>
In Reply to: <a href="8133.html">请问:应如何将muliline 的Text 列印出来?</a> posted by jan on December 08, 1998 at 17:20:39:<p>
: 请问:应如何将muliline 的Text 列印出来?<p>: 我直接用 printer.print text1.text, 但是不成功<p>'以下放于模组内即可<br>Option Explicit<br>Const EM_GETLINE = &HC4<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 Const EM_GETLINECOUNT = &HBA<br>' 计算Textbox行数<br>'使用方法如下:<br>' Dim LineCnt As Long<br>' LineCnt = TextBoxLineCnt(Text1)<br>Public Function TextBoxLineCnt(ctl As TextBox) As Long<br>  TextBoxLineCnt = SendMessage(ctl.hwnd, EM_GETLINECOUNT, 0, 0)<br>End Function<br>' 读取Textbox第N行的资料<br>' 使用方法如下:<br>' Dim str5 As String<br>' str5 = GetaLine(Text1, 1) '取得第二行的字串,以0为基底<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>  str5(0) = 255 '字串的前两个Byte存该字串的最大长度<br>  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<br>上面有API程式,你再建一个TEXTBOX控制项,将资料丢<br>进去,再一行一行印出即可.(先跟你说,这是个笨方法<br>,但一定可印) <p><p>
<br>
<br><hr size=7 width=75%><p>
<a name="followups">Follow Ups:</a><br>
<ul><!--insert: 8154-->
</ul><!--end: 8154-->
<br><hr size=7 width=75%><p>

</body></html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?