I have some code that I am having issues with.. The code blows up if the registry value doesnt exist. This is what I am trying to check for but I get an run time error because it doesnt exist.

I just want to return a value of "not" if the registry value does not exist. Can someone help me out?

Thanks! Below is the code I have (as a function). This should be pretty simple but vb6 syntax is a challenge for me.

Function checkinstalled()
Dim WSH, result, theval
Set WshShell = CreateObject("WScript.Shell")

theval = WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\InstallRoot")
If theval <> "" Then
result = "installed"
Else
result = "not"
End If

End Function