I am working on creating a code generator for registration users now I have finished my app, and I found a really good code for this, however, I get the error on the End Sub probably because of the copy/paste I do. I pasted it in the Pressed Event of a button where the code should be generated. The advice I read is that you should not use the Sub and End sub lines in the code, but without it the code give errors. Any adivce?
This is the code:
Preformatted text``Preformatted text
textUserName.Enabled = True
btnCreateRegCode.Enabled = False
txtRegLName.Text = “”
txtRegFName.Text = “”
txtOrderNr.Text = “”
txtRegEmail.Text = “”
txtRegFName.SetFocus
// Import the Crypto module
Import Crypto
// Define a constant salt value
Const salt As String = “XojoRocks”
// Define the btnCreateRegCode.Pressed event handler
Sub Pressed() Handles Pressed ’ Add this line to name the event handler
// Get the user input from the text fields
Var firstName As String = txtRegFName.Text
Var lastName As String = txtRegLName.Text
Var email As String = txtRegEmail.Text
// Add salt to the user input
Var firstNameSalted As String = firstName + salt
Var lastNameSalted As String = lastName + salt
Var emailSalted As String = email + salt
// Convert the user input to MemoryBlocks
Var firstNameMB As MemoryBlock = firstNameSalted.ToText.ConvertToData(TextEncoding.UTF8)
Var lastNameMB As MemoryBlock = lastNameSalted.ToText.ConvertToData(TextEncoding.UTF8)
Var emailMB As MemoryBlock = emailSalted.ToText.ConvertToData(TextEncoding.UTF8)
// Compute the SHA1 hashes of the MemoryBlocks
Var firstNameHashMB As MemoryBlock = Crypto.SHA1(firstNameMB)
Var lastNameHashMB As MemoryBlock = Crypto.SHA1(lastNameMB)
Var emailHashMB As MemoryBlock = Crypto.SHA1(emailMB)
// Convert the hashes to hexadecimal strings
Var firstNameHash As String = firstNameHashMB.ToHex
Var lastNameHash As String = lastNameHashMB.ToHex
Var emailHash As String = emailHashMB.ToHex
// Combine the hashes to create a registration key
Var regKey As String = firstNameHash + lastNameHash + emailHash
// Display the registration key in the text field
txtRegCode.Text = regKey
End Sub ’ Add this line to close the event handler block