VB將文字框中的漢字按拼音排序

時間 2021-08-11 17:25:08

1樓:匿名使用者

首先將漢字轉為ascii碼陣列,然後對ascii碼陣列排序。再將ascii碼陣列轉換為字元,大功告成了。

以下**經測試完全正確。

dim lasc(j) as long

private sub command1_click()dim i as long, j as long, k as long

dim r as long

dim fs as string

fs = text1.text

j = len(fs) - 1

redim lasc(j)

for i = 0 to j

lasc(i) = asc(mid(fs, i + 1, 1))next

for i = 0 to j - 1

for k = i + 1 to j

if lasc(i) > lasc(k) thenr = lasc(i)

lasc(i) = lasc(k)

lasc(k) = r

end if

next

next

fs = ""

for i = 0 to j

fs = fs & chr(lasc(i))next

text1.text = fs

end sub

2樓:匿名使用者

可以直接按照漢字的ascii值,進行大小排序:

例如:print asc("安") < asc("表")

print asc("別") < asc("稱")

3樓:聽不清啊

private sub command1_click()

a = len(text1.text)

for i = 1 to a - 1

i1 = i

for j = i + 1 to a

if asc(mid(text1.text, j, 1)) < asc(mid(text1.text, i1, 1)) then i1 = j

next j

if i1 > i then

d1$ = mid(text1.text, 1, i - 1)

d2$ = mid(text1.text, i, 1)

d3$ = mid(text1.text, i + 1, i1 - i - 1)

d4$ = mid(text1.text, i1, 1)

d5$ = mid(text1.text, i1 + 1, a - i1)

end if

text1.text = d1$ + d4$ + d3$ + d2$ + d5$

next i

end sub

vb中**如何控制按拼音字母順序來排列

4樓:匿名使用者

'list1的屬

性 sorted設為true

dim i%, j%, h$, x&

private sub command1_click()list1.clear

for i = 16 to 87

for j = 1 to 94

doevents

if chr(x) <> " " then list1.additem chr(x)

next j

next i

end sub

vb中我想在文字框中輸入某個數,然後按enter鍵之後,呼叫function

聽不清啊 private sub command1 click dim x as long x text1 yes true for i 2 to sqr x if x mod i 0 then yes false exit for end if next i if yes then label1....

中怎麼刪除文字框,而不刪除文字框中的文字

格式 文字框樣式 形狀輪廓 無輪廓,有圖可以看,這位主要是把輪廓刪除了 由穎 您的目的好像是要插入文字但卻不顯示文字框。可以右擊文字框,設定形狀格式 線條顏色 無線條。這樣的話,文字框就看不見啦 a真相背後 樓主的意思是,文字框中的文字可見,而文字框的邊界不可見,對不對呢?其實,那不叫刪除,而是隱藏...

在VB中,如何使文字框能夠使輸入多行文字

在vb中,設定文字框的multiline 屬性為true,就能使使文字框能夠輸入多行文字。multiline 屬性 返回或設定一個值,該值指示 textbox 控制元件是否能夠接受和顯示多行文字。在執行時是隻讀的。 中原一點紅先生 僅僅設定multiline屬性是沒用的。還要在輸出的時候用控制符設定...