任意输入4个字符组成一个字符串,对该字符串中的字符按ASCII码值升序排列后输出,编程实现此功能
3个回答
展开全部
Public Class Form1
'不限制输入的字符个数
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim oldStr = TextBox1.Text
Dim str(oldStr.Length - 1) As String
For i = 0 To oldStr.Length - 1
str(i) = Mid(oldStr, i + 1, 1)
Next
'这一步很关键
Array.Sort(str)
Dim newStr As String = ""
For i = 0 To oldStr.Length - 1
newStr += str(i)
Next
TextBox2.Text = newStr
End Sub
End Class
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询