问自己今天是否比明天进步了 !

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 = 1ToLen (input)
    flag = 0
    IfMid (input, a, 1) <> " "AndMid (input, a, 1) <> " "Then
      num(b) = num(b) & Mid (input, a, 1)
    Else
       If flag = 0Then b = b+1:flag = 1
         
    EndIf
Next
Dim str():ReDim str(b)
ReDimPreserve num(b)
dim c, d
a = 1
For a = 0To b
    c = 0:d = 0
    For c = 0To b
        IfIsNumeric (num(a)) = TrueAndIsNumeric (num(c)) = TrueThen
           If num(a) - num (c) > 0Then d = d+1
           Else
           If num(a) > num(c) Then d = d+1
        EndIf
    Next
    If str(d) = ""Then
      str(d) = num(a)
    Else
      str(d) = str(d) & " " & num (a)
    EndIf
Next
MsgBox str(d)
Dim vbstr:d = 0
For d = 0To 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 = "运算结果如下"
EndWith
.document.close
.MenuBar = 0
.ToolBar = 0
.AddressBar = 0
.StatusBar = 0
.Visible = true
.Resizable = 0
EndWith
WScript.Sleep10000
ie.Quit
Set ie = nothing  

TAG:

 

评分:0

我来说两句

Open Toolbar