读取单词,按字典顺序排列

liuyali16888 2010-02-28 02:54:07
各位高手,一段单词放入textbox中以后,如果让这段话按开头字母a,b,c,d............z顺序排列,求源码
...全文
107 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
liuyali16888 2010-02-28
  • 打赏
  • 举报
回复
非常非常感谢。

如果是汉字,按照拼音的第一个字母排列,是否很困难?
chinaboyzyq 2010-02-28
  • 打赏
  • 举报
回复
再加一个 List1.Clear

Private Sub Command1_Click()
Dim tmp() As String, i As Integer
tmp = Split(Text1.Text)
For i = 0 To UBound(tmp)
List1.AddItem tmp(i)
Next
For i = 0 To List1.ListCount - 1
tmp(i) = List1.List(i)
Next
Text1.Text = Join(tmp, " ")
List1.Clear
End Sub
Private Sub Form_Load()
List1.Visible = False
Text1.Text = "This example adds a centered tab stop to all the paragraphs in the selection"
End Sub
chinaboyzyq 2010-02-28
  • 打赏
  • 举报
回复
稍变动一下

Private Sub Command1_Click()
Dim tmp() As String, i As Integer
tmp = Split(Text1.Text)
For i = 0 To UBound(tmp)
List1.AddItem tmp(i)
Next
For i = 0 To List1.ListCount - 1
tmp(i) = List1.List(i)
Next
Text1.Text = Join(tmp, " ")

End Sub

Private Sub Form_Load()
List1.Visible = False
Text1.Text = "This example adds a centered tab stop to all the paragraphs in the selection"

End Sub

chinaboyzyq 2010-02-28
  • 打赏
  • 举报
回复

'设计时设置list1的Sorted属性为true(运行时不可改变)
'特殊情况自己处理,比如单词间有两个空格等
'单command1看结果

Private Sub Command1_Click()
Dim tmp() As String, i As Integer
Dim tmmp As String
tmp = Split(Text1.Text)
For i = 0 To UBound(tmp)
List1.AddItem tmp(i)
Next
For i = 0 To List1.ListCount - 1
tmmp = tmmp & List1.List(i) & " "
Next
Text1.Text = tmmp

End Sub

Private Sub Form_Load()
List1.Visible = False
Text1.Text = "This example adds a centered tab stop to all the paragraphs in the selection"

End Sub

7,763

社区成员

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

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