RT
谢谢大家,越快越好。
谢谢大家,越快越好。
解决方案 »
- 为of123() 大哥补加分数,请进
- 急问,Tdbgrid数据使用Exporttofile导入EXCEL后,如何控制不出现乱码啊?
- sql中的排序问题?
- SQL2000 中单引号是怎么处理的(‘)
- 如何去掉标题栏?
- 入门菜鸟问题之二:如何在VB里面实现数据库备份
- 请看一看我的代码,为何向DLL中传属性字符串不成功?
- 请教:Conflicting names were found in "C:\XXX\ABCD.frm",the name "ABCD" will be used.
- 自动判定问题(非高手莫入!)
- 如何用VB在access数据库中搜索内容?
- 按钮能控制下拉框吗
- 如何进行动态的权限管理?(急!!在线等)
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(7) As Byte
End TypePrivate Declare Function CoCreateGuid Lib "OLE32.DLL" (pGuid As GUID) As LongPublic Function GetGUID() As String
Dim udtGUID As GUIDIf (CoCreateGuid(udtGUID) = 0) Then GetGUID = _
String(8 - Len(Hex$(udtGUID.Data1)), "0") & Hex$(udtGUID.Data1) & _
String(4 - Len(Hex$(udtGUID.Data2)), "0") & Hex$(udtGUID.Data2) & _
String(4 - Len(Hex$(udtGUID.Data3)), "0") & Hex$(udtGUID.Data3) & _
IIf((udtGUID.Data4(0) < &H10), "0", "") & Hex$(udtGUID.Data4(0)) & _
IIf((udtGUID.Data4(1) < &H10), "0", "") & Hex$(udtGUID.Data4(1)) & _
IIf((udtGUID.Data4(2) < &H10), "0", "") & Hex$(udtGUID.Data4(2)) & _
IIf((udtGUID.Data4(3) < &H10), "0", "") & Hex$(udtGUID.Data4(3)) & _
IIf((udtGUID.Data4(4) < &H10), "0", "") & Hex$(udtGUID.Data4(4)) & _
IIf((udtGUID.Data4(5) < &H10), "0", "") & Hex$(udtGUID.Data4(5)) & _
IIf((udtGUID.Data4(6) < &H10), "0", "") & Hex$(udtGUID.Data4(6)) & _
IIf((udtGUID.Data4(7) < &H10), "0", "") & Hex$(udtGUID.Data4(7))
End IfEnd FunctionPrivate Sub Command1_Click()
MsgBox GetGUID
End Sub
Public Type GUID
Data1 As Long
Data2 As Long
Data3 As Long
Data4(8) As Byte
End Type
Private Declare Function CoCreateGuid Lib "ole32.dll" (pguid As GUID) As Long
Private Declare Function StringFromGUID2 Lib "ole32.dll" (rguid As Any, ByVal
lpstrClsId As Long, ByVal cbMax As Long) As Long
Public Function GUIDGen() As String
Dim uGUID As GUID
Dim sGUID As String
Dim bGUID() As Byte
Dim lLen As Long
Dim RetVal As Long
lLen = 40
bGUID = String(lLen, 0)
CoCreateGuid uGUID '把结构转换为一个可显示的字符串
RetVal = StringFromGUID2(uGUID, VarPtr(bGUID(0)), lLen)
sGUID = bGUID
If (Asc(Mid$(sGUID, RetVal, 1)) = 0) Then RetVal = RetVal - 1
GUIDGen = Left$(sGUID, RetVal)
End Function'使用方法
'Msgbox GUIDGen
'并保证不产生重复的GUID—重复的可能性当然存在,但有太多可用的数了,因此算法特别
'防止产生重复的数,这种情况你一生都不会看到.