Write a Dword value in Decimal in the Windows Registry

0

IneedtowriteaDwordrecordindecimalinVisualBasicExpress2013.

Howthecodewaswritten:

PrivateSubButton5_Click(senderAsObject,eAsEventArgs)HandlesButton5.ClickDimDecAsDecimalDimNumero=22IMy.Computer.Registry.SetValue("HKEY_CURRENT_USER\Software\MinhaChaveCriada",
   "DECIMAL" & Dec, Numero, Microsoft.Win32.RegistryValueKind.DWord)
End Sub

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

    
asked by anonymous 20.09.2014 / 08:53

1 answer

2

Actually you are 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)
             ------

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

Next, you concatenate ( & ) the string "DECIMAL" with Dec , thus resulting in DECIMAL0 .

To leave just DECIMAL , just remove & Dec from SetValue (and do not declare Dec if you do not want to use anything):

My.Computer.Registry.SetValue("HKEY_CURRENT_USER\Software\MinhaChaveCriada",
   "DECIMAL", Numero, Microsoft.Win32.RegistryValueKind.DWord)
    
20.09.2014 / 09:13