Hi Michel,
It's entirely possible you can determine what is going on by breaking down
your code into more readable chunks. Does the key "Settings" exist? What
about "MyProg"? Either way, its easier to see what is going on with
something like:
Dim theValue As String =
My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\ Software\MyProg\Settings",
"Articles", "80").ToString()
If theValue Is Nothing Then
' The key or part of the path does not exist
Throw New Exception ( .... )
End If
Dim theResult As Integer
If Not Integer.TryParse(theValue, theResult) Then
' A value was returned but it wasn't an integer...
Throw New Exception ( .... )
End If
Robin
Dim theSetting As
"Michel Vanderbeke" <mi***************@skynet.bewrote in message
news:uC**************@TK2MSFTNGP04.phx.gbl...
Hello,
When I want to retrieve data from the register, the defaultvalue doesn't
seem to work correctly.
iCounter =
CInt(My.Computer.Registry.Getvalue("HKEY_LOCAL_MAC HINE\Software\MyProg\Settings",
"Articles", "80"))
Is it correct that when the entry in the register does not exist, the
string "80" is taken as default?
This does not seem to work with me.
When the key Articles doesn't exist, there is no error and iCounter is set
to 80.
When the key Settings doesn't exist, there is sometimes an error and
sometimes iCounter is set to 0.
Does anyone have any idea what goes wrong?
Many thanks,
Michel