我想一行一行读出文本框中的内容,要怎么做?(online)

Seiya_ 2003-08-20 06:41:23
读文件有LINE INPUT语句,如果我要从文本框(text.text)中一行一行读呢?

比如文本有3行,分别读到text1.text\text2.text\text3.text中,要怎么做?

...全文
44 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
zyl910 2003-08-20
  • 打赏
  • 举报
回复
EM_GETLINE
An application sends an EM_GETLINE message to copy a line of text from an edit control and place it in a specified buffer.

EM_GETLINE
wParam = (WPARAM) line; // line number to retrieve
lParam = (LPARAM) (LPCSTR) lpch; // address of buffer for line

Parameters
line
Value of wParam. Specifies the zero-based index of the line to retrieve from a multiline edit control. A value of zero specifies the topmost line. This parameter is ignored by a single-line edit control.
lpch
Value of lParam. Pointer to the buffer that receives a copy of the line. The first word of the buffer specifies the maximum number of characters that can be copied to the buffer.
Return Values
The return value is the number of characters copied. The return value is zero if the line number specified by the line parameter is greater than the number of lines in the edit control.

Remarks
The copied line does not contain a terminating null character.

QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Requires version 1.0 or later.
Header: Declared in winuser.h.
Wang_xiaoni 2003-08-20
  • 打赏
  • 举报
回复
把文件存为一个临时文件,然后再readln
danielinbiti 2003-08-20
  • 打赏
  • 举报
回复
Private Declare Sub RtlMoveMemory Lib "kernel32.dll" (Destination As Any, Source As Any, ByRef length As Long)
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
Const EM_GETLINE = &HC4

Private Sub Command1_Click()
Dim s As String, length As Integer
length = 80
s = String(length, Chr(0))
RtlMoveMemory ByVal s, length, 2
SendMessage Text1.hwnd, EM_GETLINE, 2, ByVal s
s = Left(s, InStr(s, Chr(0)) - 1)
End Sub
或者一行行读回车。读到相应的行数时再把它读出来

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧