如何将多行TextBox转换成ListBox
来源:互联网 发布:鼠标宏怎么编程 编辑:程序博客网 时间:2024/05/16 10:55
如何将多行TextBox转换成ListBox
老怪答:
本题解法重点在 TextBox 里的断行,必须由 Chr(13)+Chr(10) 两字组合起来执行,所以应以 Chr(13) 为切割判断点:
Dim AllString As String
Dim SingleString As String
Dim SepString As String
Dim I As Long
AllString = Text1.Text
For I = 1 To Len(AllString)
SingleString = Mid(AllString, I, 1)
If SingleString = Chr(13) Then
'遇到 Chr(13) 则把分割字符串加到 ListBox 里
List1.AddItem SepString
SepString = ""
Else
If SingleString <> Chr(10) Then
'除 Chr(10) 外逐字加入 SepString 中
SepString = SepString + SingleString
End If
End If
Next
'加入最后一个 SepString
List1.AddItem SepString
CWW 来函意见:
拆解多行 TextBox 这限制在MultiLine而且有Keyin Enter来换行的TextBox,如果MultiLine之下一直KeyIn不换行,到了TextBox最右
边后,再Keyin的字会折下来,变成另一行,这方式解决不了,请查一下
htmapi101.htm的做法。
取得TextBox 某一行的字串
來源:cww
這是使用EM_GETLINE message來做,比較奇特的是lParam是指向一個字串所在的位置,
但是該字串傳入時,前兩個Byte要存該字串允許的最大長度。'以下在Form需一個TextBox,並設定MultiLine = True, 一個Command ButtonPrivate Sub Command1_Click()Dim str5 As Stringstr5 = GetaLine(Text1,1) '取得第二行的字串,以0為基底End Sub'以下在.BasOption Explicit Const EM_GETLINE = &HC4 Declare Function SendMessage Lib "user32" Alias "SendMessageA" _ (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _ lParam As Any) As Long Public Function GetaLine(Text1 As TextBox, ByVal ntx As Long) As String Dim str5(255) As Byte '如果您的字串 > 255 byte請自行增加該Byte Array Dim str6 As String, i As Long str5(0) = 255 '字串的前兩個Byte存該字串的最大長度 str5(0) = 255 i = SendMessage(Text1.hwnd, EM_GETLINE, ntx, str5(0)) If i = 0 Then GetaLine = "" Else str6 = StrConv(str5, vbUnicode) GetaLine = Left(str6, InStr(1, str6, Chr(0)) - 1) End If End Function
- 如何将多行TextBox转换成ListBox
- 选中ListBoxItem中的TextBox后,如何改变ListBox的SelectedItem?
- 输入textBox查找listBox内容
- c#中如何将byte数组转换成string从而在textbox中显示出来?
- Textbox+listbox实现自动完成功能
- textbox+listbox,用键盘选择(上下)
- 输入textbox查找listbox 内容符合项
- gridview 自动列转换成textbox
- VB.NET数据源与ListBox,ComboBox,TextBox的数据绑定
- 将textbox中的文本加入listbox,并可删除listbox的项。
- 在c#中如何将textbox中的回车符转换为html中的换行符<br>
- 如何获取listbox中控件
- 如何设置让combox 显示成TextBox 样子.
- 索引色转换成RGB色-listbox中使用索引色
- 如何改变TextBox的高度
- 如何动态添加textbox (Jquery)
- TextBox文本框中如何换行
- TextBox如何触发TextChanged事件
- Head First C# 中文版 图文皆译 第八章 枚举和集合 page330
- 在C#中取得TextBox多行文本的行、列位置与定位
- 4月10日,第5封信
- linux test tool
- I-P-B frame简介
- 如何将多行TextBox转换成ListBox
- VB 快速读取TextBox第N行的数据
- 怎样得到文本框(TextBox)中的文本行数?
- 数据库 RichBox中的回车与空格的解决方案!
- Python
- “T+1”交易制度
- 汇编指令与机器码的相互转换
- 一个公务员工作七年后的肺腑之言”——给想考公务员的XDJM们看看,或许能有帮助
- 关于Opera的职位