真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

vb點虐 字符串排序 vb字符串反序怎么弄

vb點虐 如何對數(shù)據(jù)庫查詢結(jié)果記錄集排序?

加了單引號就是一個常量字符串了,對于每一行都是一樣的

創(chuàng)新互聯(lián)建站服務(wù)項目包括樂平網(wǎng)站建設(shè)、樂平網(wǎng)站制作、樂平網(wǎng)頁制作以及樂平網(wǎng)絡(luò)營銷策劃等。多年來,我們專注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢、行業(yè)經(jīng)驗、深度合作伙伴關(guān)系等,向廣大中小型企業(yè)、政府機構(gòu)等提供互聯(lián)網(wǎng)行業(yè)的解決方案,樂平網(wǎng)站推廣取得了明顯的社會效益與經(jīng)濟效益。目前,我們服務(wù)的客戶以成都為中心已經(jīng)輻射到樂平省份的部分城市,未來相信會繼續(xù)擴大服務(wù)區(qū)域并繼續(xù)獲得客戶的支持與信任!

像這種放在最前面的字段,order by 1 就可以了

VB 字符串排序

Option Explicit

Private Sub Command1_Click() '排序

Dim i%, j%, S() As String, t As String

ReDim S(Len(Trim(Text1)))

For i = LBound(S) To UBound(S)

S(i) = Mid(Trim(Text1), i + 1, 1)

Next

For i = 0 To UBound(S)

For j = i + 1 To UBound(S)

If S(j) S(i) Then t = S(i): S(i) = S(j): S(j) = t

Next

Text2 = Text2 S(i)

Text2 = Trim(Text2)

Next

End Sub

Private Sub Command2_Click() '讀入

Dim Txt As String

Open App.Path "\test12.txt" For Input As #11

Do While Not EOF(11)

Line Input #11, Txt

Text1 = Text1 Txt

Loop

Close #11

End Sub

Private Sub Command3_Click() '追加

Open App.Path "\test12.txt" For Append As #12

Print #12, Text2

Close #12

End Sub

VB怎么使一個字符串按要求排序?就是字符串里面有數(shù)字和字母。先按字母在前。數(shù)字在后面。字母和數(shù)字也

什么都不說,先上效果圖——

編碼——

Private Sub Command1_Click()

Dim s1 As String, s_num As String, a As String

Dim lennum As Integer, lenuchar As Integer, lenlchar As Integer

Dim s_lchar As String, s_uchar As String

Dim i As Integer, length As Integer, value As Integer

s1 = Text1.Text

s_num = "" ????????'用來存放數(shù)字的字符串變量

s_uchar = ""????????'用來存放大寫字母的字符串變量

s_lchar = ""????????'用來存放小寫字母的字符串變量

length = Len(s1)

For i = 1 To length

a = Mid(s1, i, 1)

value = Asc(a)

Text2.Text = value

If value = 48 And value = 57 Then s_num = s_num a

If value = 65 And value = 90 Then s_uchar = s_uchar a

If value = 97 And value = 122 Then s_lchar = s_lchar a

Next i

' 把字符串中的各種字符分類成 數(shù)字類,大寫字母,小寫字母

lennum = Len(s_num)

lenuchar = Len(s_uchar)

lenlchar = Len(s_lchar)

Dim sz() As Integer ? ?'定義動態(tài)數(shù)組

Dim temp As Integer

ReDim sz(1 To lennum) As Integer ? '定義數(shù)組供 數(shù)字的ASCII碼

For i = 1 To lennum

a = Mid(s_num, i, 1)

sz(i) = Asc(a)

Next i

For i = lennum To 1 Step -1 ? ? ? ? '最常用的冒泡排序法

For j = 1 To i - 1

? If sz(j) sz(j + 1) Then temp = sz(j): sz(j) = sz(j + 1): sz(j + 1) = temp

Next j

Next i

s_num = "" ? ? ? ? ? ? ?'清空s_num ,因為要重新排列了

For i = 1 To lennum

s_num = s_num Chr(sz(i))

Next i

ReDim sz(1 To lenuchar) As Integer ?'重新定義數(shù)組供 大寫字母的ASCII碼,接下來程序思路與上面類似

For i = 1 To lenuchar

a = Mid(s_uchar, i, 1)

sz(i) = Asc(a)

Next i

For i = lenuchar To 1 Step -1

For j = 1 To i - 1

? If sz(j) sz(j + 1) Then temp = sz(j): sz(j) = sz(j + 1): sz(j + 1) = temp

Next j

Next i

s_uchar = ""

For i = 1 To lenuchar

s_uchar = s_uchar Chr(sz(i))

Next i

ReDim sz(1 To lenlchar) As Integer ?'重新定義數(shù)組供 小寫字母的ASCII碼,接下來程序思路與上面類似

For i = 1 To lenlchar

a = Mid(s_lchar, i, 1)

sz(i) = Asc(a)

Next i

For i = lenlchar To 1 Step -1

For j = 1 To i - 1

? If sz(j) sz(j + 1) Then temp = sz(j): sz(j) = sz(j + 1): sz(j + 1) = temp

Next j

Next i

s_lchar = ""

For i = 1 To lenlchar

s_lchar = s_lchar Chr(sz(i))

Next i

Text2.Text = s_uchar s_lchar s_num

End Sub

該程序主要運用了Asc()函數(shù)獲得ASCII碼來分辨字母與數(shù)字,用 動態(tài)數(shù)組和重定義來多次運用數(shù)組進行排序(冒泡排序法)和賦值操作,用chr()函數(shù)還原字符串。

我的程序有點略長,中間有少許重復(fù)部分,但我覺得思路比較清晰易懂,適合初學者。你也可以試著自己改進。


當前題目:vb點虐 字符串排序 vb字符串反序怎么弄
URL分享:http://weahome.cn/article/ddcjchs.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部