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

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

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

x = val("&h" + hex(i + 160) + hex(j + 160))

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

next j

next i

end sub

vb中怎麼儲存文字框中的內容,VB怎麼將文字框的內容儲存到txt

不能寫入乙個ini檔案或者txt檔案儲存設定麼?不涉及到資料庫。需要的話給你個小例子看。vb怎麼將文字框的內容儲存到txt private subtext1 change open d data.txt foroutput as 1 print 1,text1 close 1end sub 這樣還是...

VB中,如何實現 當滑鼠點選文字框時,文字框內的提示字元會自

option explicit dim defs as string private sub form activate defs 請在這裡輸入 定義提示字元command1.setfocus 給按鈕置焦點end sub private sub text1 gotfocus 文字框得到焦點 if t...

VB中如何輸入文字框文字輸入字元,在這字元後加上

private sub text1 change if len text1.text 4 then text1.text text1.text end sub 我精心寫了一段哦!現在針對的是text1這個控制元件只需要放一個text1控制元件在窗體上在複製這段 貼上執行就可以了。我想了3種方法,一個...