vb 解释一下这段代码,有难度可以再加分!

来源:百度知道 编辑:UC知道 时间:2024/09/18 03:41:22
有没有人帮我解释一下这段代码?这是一高人帮我写的.我是初学者看不太懂,尽量详细一点!还有哪些跟哪些联系在一块的!谢谢!!'以下是排序按钮
Private Sub Command1_Click()
Dim a1, i, s, n
a1 = Split(Text1.Text, vbCrLf)
If Right(Text1.Text, 1) = Chr(10) Then n = UBound(a1) - 1 Else n = UBound(a1)
For i = LBound(a1) To n
s = s & i + 1 & " " & strpx(Right(Trim(a1(i)), 14)) & vbCrLf
Next
Text2.Text = s
End Sub
Public Function strpx(ByVal s As String) As String
'排序过程
Dim i, j As Integer
Dim a, temp
a = Split(s, " ")
For i = LBound(a) To UBound(a)
For j = i To UBound(a)
If Val(a(i)) > Val(a(j)) Then
temp = a(i): a(i) = a(j): a(j) = temp
End If
Next
Next
strpx = Join(a, " ")
End Function
Public Function total(ByVal s As String) As Single
'求和过程
Dim sum As Single
Dim a, x
sum = 0
a = Split(s, " ")
For Each x In a
sum = sum + Val(x

Private Sub Command1_Click()
Dim a1, i, s, n
a1 = Split(Text1.Text, vbCrLf) '把text1的内容按行分割成数组
If Right(Text1.Text, 1) = Chr(10) Then n = UBound(a1) - 1 Else n = UBound(a1) '判断最后一行是不是空行
For i = LBound(a1) To n
s = s & i + 1 & " " & strpx(Right(Trim(a1(i)), 14)) & vbCrLf '调用strpx排序过程,把每一行的数字排序后再连接起来
Next
Text2.Text = s '把排序后的内容显示在text2
End Sub
Public Function strpx(ByVal s As String) As String
'排序过程
Dim i, j As Integer
Dim a, temp
a = Split(s, " ") '把每一行的内容按空格,再分割成数组
For i = LBound(a) To UBound(a)
For j = i To UBound(a)
If Val(a(i)) > Val(a(j)) Then '按从小到大数序排序
temp = a(i): a(i) = a(j): a(j) = temp
End If
Next
Next
strpx = Join(a, " ") '把排序后的数字再用空格连接起来
End Function
Public Function total(ByVal s As String) As Single
'求和过程
Dim sum As Single
Dim a, x
sum = 0
a =