Support Forums

Full Version: [Help]GUID
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Can Anyone give me the Code To Generate a GUID
and Make it Appear in The Textbox1
Yes, ive tried google but, seriously nothing has worked >.<
Thanks[:
Code:
Public Class Form1
Dim theGUID As String

Private Sub Button_Click
theGUID = System.Guid.NewGuid.ToString()
TextBox1.Text = theGUID
End Sub

End Class

Pretty easy..
Doesnt Work =/
Works perfectly fine for me? Paste your exact code & I'll take a look.
Code:
Public Class Form1
    Dim GUID As String


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        GUID = System.Guid.NewGuid.ToString()
        TextBox1.Text = GUID
End Sub
End Class
Picture:
[As Dubstep Code]
[Image: guidgen.jpg]
This code will get the GUID value using a RegisteryKey

First we will import Microsoft.Win32(Put this above the class declaration):
Code:
Imports Microsoft.Win32

Now for the GUID Value code:
Code:
Dim regKey As RegistryKey
Dim GUID As String
regKey = Registry.LocalMachine.OpenSubKey("Software\Microsoft\Cryptography", True)
GUID = regKey.GetValue("MachineGuid")
regKey.Close()

The GUID will be stored in the variable "GUID".