zoukankan
html css js c++ java
vb的GUID生成算法
源代码推荐:vb的GUID生成算法
'
RETURNS: GUID if successful; blank string otherwise.
'
Unlike the GUIDS in the registry, this function returns GUID
'
without "-" characters. See comments for how to modify if you
'
want the dash.
Public
Function
GUID()
As
String
Dim
lRetVal
As
Long
Dim
udtGuid
As
GUID
Dim
sPartOne
As
String
Dim
sPartTwo
As
String
Dim
sPartThree
As
String
Dim
sPartFour
As
String
Dim
iDataLen
As
Integer
Dim
iStrLen
As
Integer
Dim
iCtr
As
Integer
Dim
sAns
As
String
On
Error
GoTo
errorhandler
sAns
=
""
lRetVal
=
CoCreateGuid(udtGuid)
If
lRetVal
=
0
Then
'
First 8 chars
sPartOne
=
Hex
$(udtGuid.PartOne)
iStrLen
=
Len
(sPartOne)
iDataLen
=
Len
(udtGuid.PartOne)
sPartOne
=
String
((iDataLen
*
2
)
-
iStrLen,
"
0
"
) _
&
Trim
$(sPartOne)
'
Next 4 Chars
sPartTwo
=
Hex
$(udtGuid.PartTwo)
iStrLen
=
Len
(sPartTwo)
iDataLen
=
Len
(udtGuid.PartTwo)
sPartTwo
=
String
((iDataLen
*
2
)
-
iStrLen,
"
0
"
) _
&
Trim
$(sPartTwo)
'
Next 4 Chars
sPartThree
=
Hex
$(udtGuid.PartThree)
iStrLen
=
Len
(sPartThree)
iDataLen
=
Len
(udtGuid.PartThree)
sPartThree
=
String
((iDataLen
*
2
)
-
iStrLen,
"
0
"
) _
&
Trim
$(sPartThree)
'
Next 2 bytes (4 hex digits)
'
Final 16 chars
For
iCtr
=
0
To
7
sPartFour
=
sPartFour
&
_
Format$(
Hex
$(udtGuid.PartFour(iCtr)),
"
00
"
)
Next
'
To create GUID with "-", change line below to:
'
sAns = sPartOne & "-" & sPartTwo & "-" & sPartThree _
'
& "-" & sPartFour
sAns
=
sPartOne
&
sPartTwo
&
sPartThree
&
sPartFour
End
If
GUID
=
sAns
Exit
Function
errorhandler:
'
return a blank string if there's an error
Exit
Function
End Function
查看全文
相关阅读:
Asp.Net构架(Http请求处理流程)、(Http Handler 介绍)、(HttpModule 介绍)
JQuery中的事件(三)
关于asp.net mvc中的httpModules 与 httpHandler
jQuery中的CSS(二)
JQuery选择器(一)
JavaScript中利用Ajax 实现客户端与服务器端通信(九)
JavaScriptDom操作与高级应用(八)
oracle(二)V$lock 视图中ID1 , ID2 列的含义
关于static、内部类
oracle(一)复习起航
原文地址:https://www.cnblogs.com/todd/p/104550.html
最新文章
mysqldump 和 sql命令导入sql文件
iconv
discuz uc_server 配置登录
tar
远程拉取,推送文件包
火狐,discuz同步登录问题解决
.gitignore 无效问题
NFS 简介
NFS
Kubernetes kubectl 命令
热门文章
kubectl get 输出格式
Kubernetes 相关概念
Kubernetes 简介
Kubernetes
Docker Compose
Docker Dockerfile
Docker 网络管理
JQuery中的Ajax(六)
JQuery中的工具类(五)
JQuery动画详解(四)
Copyright © 2011-2022 走看看