vb用function函数将一个任意长度的字符串按每个字符的ASC码由小到大排列后输出
答案:2 悬赏:70 手机版
解决时间 2021-03-07 11:44
- 提问者网友:爱了却不能说
- 2021-03-07 07:47
vb用function函数将一个任意长度的字符串按每个字符的ASC码由小到大排列后输出
最佳答案
- 五星知识达人网友:过活
- 2021-03-07 08:53
Function SortASCIi(ByVal s As String) As String
Dim i As Integer, j As Integer, t As String
For i = 1 To Len(s) - 1
For j = i + 1 To Len(s)
If Mid(s, i, 1) > Mid(s, j, 1) Then
t = Mid(s, i, 1)
Mid(s, i, 1) = Mid(s, j, 1)
Mid(s, j, 1) = t
End If
Next j
Next i
SortASCII = s
End Function
Private Sub Command1_Click()
MsgBox SortASCIi("hy1uyti0yj4325fghfnm7455768nbmgjh009789dsfs1ffd2hhk3uk")
End Sub
Dim i As Integer, j As Integer, t As String
For i = 1 To Len(s) - 1
For j = i + 1 To Len(s)
If Mid(s, i, 1) > Mid(s, j, 1) Then
t = Mid(s, i, 1)
Mid(s, i, 1) = Mid(s, j, 1)
Mid(s, j, 1) = t
End If
Next j
Next i
SortASCII = s
End Function
Private Sub Command1_Click()
MsgBox SortASCIi("hy1uyti0yj4325fghfnm7455768nbmgjh009789dsfs1ffd2hhk3uk")
End Sub
全部回答
- 1楼网友:拜訪者
- 2021-03-07 09:53
汉字如何处理?
要说它的“ASCII码”,在VB中,它都是负数呢。
再看看别人怎么说的。
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯