不错呦!smile@林凯西,确保“准备文件”中的几个文件都有安装,S...您好,看了您这篇帖子觉得很有帮助。但是有个问题想请...我的修改过了怎么还被恶意注册呢 @jjjjiiii 用PJ快9年了,主要是A...PJ3啊,貌似很少有人用PJ了,现在不是WP就是z...@332347365,我当时接入时错误码没有-10...楼主,ChkValue值应为-103是什么意思呢?...大哥 你最近能看到我发的信息,请跟我联系,我有个制...
VB6.0 Dictionary排序
编辑:dnawo 日期:2009-09-28
复制内容到剪贴板
程序代码

Option Explicit
Private Sub Form_Load()
Dim dict As Scripting.Dictionary
Dim item
Set dict = CreateObject("Scripting.Dictionary")
dict.Add "aaa", 1
dict.Add "ccc", 7
dict.Add "bbb", 5
SortDictionary dict, 1 '排序
For Each item In dict
Text1.Text = Text1.Text & item & "," & dict(item) & vbCrLf
Next
End Sub
'说明:Dictionary排序
'参数:
' objDict:Dictionary对象
' intSort: 1 根据key排序; 2 根据value排序
Function SortDictionary(objDict, intSort)
' declare our variables
Dim strDict()
Dim objKey
Dim strKey, strItem
Dim X, Y, Z
' get the dictionary count
Z = objDict.Count
' we need more than one item to warrant sorting
If Z > 1 Then
' create an array to store dictionary information
ReDim strDict(Z, 2)
X = 0
' populate the string array
For Each objKey In objDict
strDict(X, 1) = CStr(objKey)
strDict(X, 2) = CStr(objDict(objKey))
X = X + 1
Next
' perform a a shell sort of the string array
For X = 0 To (Z - 2)
For Y = X To (Z - 1)
If StrComp(strDict(X, intSort), strDict(Y, intSort), vbTextCompare) > 0 Then
strKey = strDict(X, 1)
strItem = strDict(X, 2)
strDict(X, 1) = strDict(Y, 1)
strDict(X, 2) = strDict(Y, 2)
strDict(Y, 1) = strKey
strDict(Y, 2) = strItem
End If
Next
Next
' erase the contents of the dictionary object
objDict.RemoveAll
' repopulate the dictionary with the sorted information
For X = 0 To (Z - 1)
objDict.Add strDict(X, 1), strDict(X, 2)
Next
End If
End Function
Private Sub Form_Load()
Dim dict As Scripting.Dictionary
Dim item
Set dict = CreateObject("Scripting.Dictionary")
dict.Add "aaa", 1
dict.Add "ccc", 7
dict.Add "bbb", 5
SortDictionary dict, 1 '排序
For Each item In dict
Text1.Text = Text1.Text & item & "," & dict(item) & vbCrLf
Next
End Sub
'说明:Dictionary排序
'参数:
' objDict:Dictionary对象
' intSort: 1 根据key排序; 2 根据value排序
Function SortDictionary(objDict, intSort)
' declare our variables
Dim strDict()
Dim objKey
Dim strKey, strItem
Dim X, Y, Z
' get the dictionary count
Z = objDict.Count
' we need more than one item to warrant sorting
If Z > 1 Then
' create an array to store dictionary information
ReDim strDict(Z, 2)
X = 0
' populate the string array
For Each objKey In objDict
strDict(X, 1) = CStr(objKey)
strDict(X, 2) = CStr(objDict(objKey))
X = X + 1
Next
' perform a a shell sort of the string array
For X = 0 To (Z - 2)
For Y = X To (Z - 1)
If StrComp(strDict(X, intSort), strDict(Y, intSort), vbTextCompare) > 0 Then
strKey = strDict(X, 1)
strItem = strDict(X, 2)
strDict(X, 1) = strDict(Y, 1)
strDict(X, 2) = strDict(Y, 2)
strDict(Y, 1) = strKey
strDict(Y, 2) = strItem
End If
Next
Next
' erase the contents of the dictionary object
objDict.RemoveAll
' repopulate the dictionary with the sorted information
For X = 0 To (Z - 1)
objDict.Add strDict(X, 1), strDict(X, 2)
Next
End If
End Function
参考:
·排序的 String 类型的值的数据填充的脚本字
评论: 0 | 引用: 0 | 查看次数: 9242
发表评论
请登录后再发表评论!