问自己今天是否比明天进步了 !
vbs排序算法2
上一篇 /
下一篇 2011-11-30 08:56:15
/ 个人分类:QTP学习
Dim input, num()
input = InputBox ("请输入,注意将要排序的字符用空格格开:")
ReDim num(Len (input))
Dim a, b:b = 0
For a = 1 To Len (input)
flag = 0
If Mid (input, a, 1) <> " " And Mid (input, a, 1) <> " " Then
num(b) = num(b) & Mid (input, a, 1)
Else
If flag = 0 Then b = b+1:flag = 1
End If
Next
Dim str():ReDim str(b)
ReDim Preserve num(b)
dim c, d
a = 1
For a = 0 To b
c = 0:d = 0
For c = 0 To b
If IsNumeric (num(a)) = True And IsNumeric (num(c)) = True Then
If num(a) - num (c) > 0 Then d = d+1
Else
If num(a) > num(c) Then d = d+1
End If
Next
If str(d) = "" Then
str(d) = num(a)
Else
str(d) = str(d) & " " & num (a)
End If
Next
MsgBox str(d)
Dim vbstr:d = 0
For d = 0 To b
vbstr = vbstr & " " & str(d)
Next
Set ie = WScript.CreateObject("internetexplorer.application")
With ie
.Navigate "about:blank"
.Width = 400
.Height = 200
With .Document.parentwindow
.moveto (.Screen.AvailWidth-400)/2,(.Screen.AvailHeight-200)/2
.Document.Write "<FONT face=楷体_GB2312 color=#FF9224 size=3><br>排序前:" & input & "<br>排序后:" & right(vbstr, len(vbstr)-1) & "</font></br><body bgcolor='#8020ff'></br>"
.Document.title = "运算结果如下"
End With
.document.close
.MenuBar = 0
.ToolBar = 0
.AddressBar = 0
.StatusBar = 0
.Visible = true
.Resizable = 0
End With
WScript.Sleep 10000
ie.Quit
Set ie = nothing
收藏
举报
TAG: