How to use VB. NET to generate guid

Source: Internet
Author: User
Tags net command

For various reasons, developers use a globally unique identifier (guid). For example, a guid is assigned to a global identifier in a class or used when processing a database. GUID is the Globally Unique Identifier (UUID) of Microsoft Distributed Computing Environment (DCE. GUID is a 128-bit globally unique identifier, which is automatically generated based on constantly changing factors.

There is a very small possibility that the guid value may be zero, or it may be equal to other guids. You can use guid to access all computers or networks that require a unique identifier.

Guid can identify the interface or Class Object. A guid consists of a group of eight hexadecimal numbers and three groups of four hexadecimal numbers (that is, a group of 12 hexadecimal numbers.

In the following script, I manually generate a guid, and I used it in subsequent applications using VB. NET:

Private sub generateguid ()

Dim sguid as string

Sguid = system. guid. newguid. tostring ()

MessageBox. Show (sguid)

End sub

In this example, I defined a string variable, sguid, which is used to save the generated guid. Then, I will assign the return value of the system. guid. newguid (using the system. guid namespace) method to sguid, and then use tostring () to convert the result to the string type. In this way, the result is displayed in the message dialog box.

Note: Visual Studio. Net allows you to generate guid interactively by running Visual Studio. NET command prompt. You can visit the msdn website for more detailed information. You can also refer to another article in techrepublic.Article"Generating and working with guids in. net ."

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.