Generating a GUID with VB.NET

前端之家收集整理的这篇文章主要介绍了Generating a GUID with VB.NET前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

Introduction

This code generates Globally Unique Identifier (GUID),which can be used to uniqually identify elements in a database.

GUIDs identify objects such as interfaces and class objects. A GUID consists of one group of 8 hexadecimal digits,followed by three groups of 4 hexadecimal digits each,which are followed by one group of 12 hexadecimal digits.

Possessing a unique identifier makes it easy to store and retrieve information. This is especially useful when working with a database because a GUID makes an excellent primary key.

SQL Server integrates well with GUID usage. The sql Server data type uniqueidentifier stores a GUID value. You can either generate this value within sql Server—using the NEWID() function—or you can generate the GUID outside of sql Server and insert it manually.

The base System class in the .NET Framework includes the GUID value type. In addition,this value type includes methods to work with GUID values. In particular,the NewGUID method allows you to easily generate a new GUID.

Language and Platform

VB.NET 2005

Compiler

This code segment is for VB.NET 2005

Version

1.0.0.0

Code

    Private Sub GenerateGUID()
        Dim strGUID As String        
        strGUID = System.Guid.NewGuid.ToString()        
        MessageBox.Show(strGUID )
    End Sub

原文链接:https://www.f2er.com/vb/264136.html

猜你在找的VB相关文章