當前位置:編程學習大全網 - 編程軟體 - 用vbscript或jsscript編寫小程序

用vbscript或jsscript編寫小程序

'將下列代碼保存到壹個文本文檔中然後將後綴名改為vbs即可執行:

Dim?i,?int1(3),?str1(3),?s

int1(0)?=?22

int1(1)?=?14

int1(2)?=?6

int1(3)?=?13

Call?sortFigu(int1)'調用過程進行處理

For?i?=?LBound(int1)?To?UBound(int1)

s?=?s?&?CStr(int1(i))?&?"?"

Next

MsgBox?s'顯示int1排序後的結果

str1(0)?=?"d"

str1(1)?=?"a"

str1(2)?=?"j"

str1(3)?=?"b"

Call?sorString(str1)'調用過程進行處理

s?=?""

For?i?=?LBound(str1)?To?UBound(str1)

s?=?s?&?CStr(str1(i))?&?"?"

Next

MsgBox?s'顯示str1排序後的結果

Private?Sub?sortFigu(ByRef?int1)'數字數組升序排序

Dim?i,?j,?temp

For?i?=?LBound(int1)?To?UBound(int1)

For?j?=?i?To?UBound(int1)

If?int1(i)?>?int1(j)?Then

temp?=?int1(i)

int1(i)?=?int1(j)

int1(j)?=?temp

End?If

Next

Next

End?Sub

Private?Sub?sorString(ByRef?str1)'字符數組降序排序

Dim?i,?j,temp

For?i?=?LBound(str1)?To?UBound(str1)

For?j?=?i?To?UBound(str1)

If?str1(i)?<?str1(j)?Then

temp?=?str1(i)

str1(i)?=?str1(j)

str1(j)?=?temp

End?If

Next

Next

End?Sub

'以上只是個演示,裏面的兩個過程妳可以放到妳的網頁中調用

  • 上一篇:lut4延遲鏈
  • 下一篇:c# TCP聊天程序的IP地址設置
  • copyright 2024編程學習大全網