Write a Dword value to Decimal in the Windows Register

Asked

Viewed 486 times

1

SS

I need to record a decimal Dword record in Visual Basic Express 2013.

How the code was written:

Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
    Dim Dec As Decimal
    Dim Numero = 22I
    My.Computer.Registry.SetValue("HKEY_CURRENT_USER\Software\MinhaChaveCriada",
   "DECIMAL" & Dec, Numero, Microsoft.Win32.RegistryValueKind.DWord)
End Sub

When write to the record it is adding a 0 "ZERO" in front of the creation text that would be "DECIMAL" only and not DECIMAL0 it always puts that zero.

1 answer

2


In fact you are the one who is adding a zero in front of the text, in this line:

My.Computer.Registry.SetValue("HKEY_CURRENT_USER\Software\MinhaChaveCriada",
   "DECIMAL" & Dec, Numero, Microsoft.Win32.RegistryValueKind.DWord)
             ------

How do you define that Dec is decimal, but does not assign any value, Dec remains initialized with the value 0.

Then you concatenate (operator &) the string "DECIMAL" with Dec, therefore resulting in DECIMAL0.

To leave only DECIMAL, just remove the & Dec of SetValue (or declare the variable Dec if you don’t want to use for anything):

My.Computer.Registry.SetValue("HKEY_CURRENT_USER\Software\MinhaChaveCriada",
   "DECIMAL", Numero, Microsoft.Win32.RegistryValueKind.DWord)
  • The only reason I don’t kiss you is 'cause you’re a man' .

  • This is how it is for those who are working with the records. Private Sub Button5_click(Sender As Object, and As Eventargs) Handles Button5.Click Dim Numero = 22I My.Computer.Registry.Setvalue("HKEY_CURENT_USER Software Menvecriad", "DECIMAL", Numero, Microsoft.Win32.RegistryValueKind.Dword) End Sub

Browser other questions tagged

You are not signed in. Login or sign up in order to post.