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
查看全文
相关阅读:
30分钟掌握ES6/ES2015的核心内容(上)
rem 响应式用法
angular框架MVVM
vue3 + vite + elmentui
vue3 + vite + elmentui
vue3 + vite 开发新项目
滚动条滚动加一个进度条
jquery 截取页面 url ,切换新的url 跳转
h5,css3
前端模板预编译技术
原文地址:https://www.cnblogs.com/todd/p/104550.html
最新文章
Vue 2.0初学后个人总结及分享
weui.css中flex容器下子项目的水平和垂直居中
产生一百个不重复的随机数
Lua 学习记录(一),使用OpenResty搭建接口服务器
使用webpack热加载,开发多页面web应用
webStorm支持.wxml文件高亮显示
使用sui实现的选择控件【性别、日期、省市级联】
IE8+等兼容、360调用webkit内核小记
jQuery 扩展 【ajax实例】
落家
热门文章
CodingLife主题更新
在pcduino上实现图像识别的程序
pcduino在ros底下安装opencv
pcduino重装ubuntu系统
Visual Studio 2015 开发MVC4出现错误
从反编译的角度去观察C#6.0
MVC 5.0 之奇葩错误-<类型“ASP._Page__ViewStart_cshtml”不从“System.Web.WebPages.StartPage”继承>
antd Calendar日历组件
react 倒计时 countDown
30分钟掌握ES6/ES2015核心内容(下)
Copyright © 2011-2022 走看看