怎樣得到文字框(TextBox)中的文字行數?

2021-04-26 13:00:39 字數 845 閱讀 3623

怎樣得到文字框(textbox)中的文字行數?

計算文字框中輸入文字的行數可以使用sendmessage函式返回,當一行文字發生環繞時,它將被當作新的一行,而被非簡單的計算文字中的換行符個數。

把以下api函式的宣告添入模組檔案的general declarations區域,如果您使用的是vb4-32或vb5,也可以把此宣告添入form1的general declarations中,並把所有的「public」更換為「private」。

option explicit

public declare function sendmessagelong lib _

"user32" alias "sendmessagea" _

(byval hwnd as long, _

byval wmsg as long, _

byval wparam as long, _

byval lparam as long) as long

public const em_getlinecount = &hba

form code

sub text1_change()

dim linecount as long

on local error resume next

'得到/顯示文字行數

linecount = sendmessagelong(text1.hwnd, em_getlinecount, 0&, 0&)

label1 = format$(linecount, "##,###")

end sub

注釋:為了使本程式成功,請在設計階段把文字框的multiline屬性設為true。

文字框日曆

建立頭部 document.write 734 8 建立星期條目 document.write for i 0 i 7 i document.write week i document.write 建立日期條目 document.write for i 0 i 6 i document.write ...

文字框排版

文字框排版 我們之前學看文件的排版設定技巧,那麼還有乙個是文字框的排版設定,除了前面介紹到的段落排版以外,我們經常用到的還有文字框的排版,文字框排版在現實當中實踐應用包括了年會主持詞製作手卡的一些工作場景,那麼我們接下來就製作一下,首先在乙個空白文件中我們插入乙個文字框。插入文字框之後,清楚當中的預...

TextBox伺服器控制項怎麼操作,文字框的多行換行

例如,我有個textbox,己將它的textmode屬性設定成 multiline 如下 如果您希望換行成 測試中 那麼它text屬性值應該是 也就是說,您如果把 我要 r n存檔 存入資料庫,撈出來顯示在textmode為multiline的textbox 上,就會有你要的效果。如果您存入資料庫時...