Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to read (Default) key value from registry using VB6;

What I have tried:

VB.NET
Private Sub cmdRDetails_Click()
Dim strResult As String
strResult = strResult & GetMeRegistry("ABC.OCX") + vbCrLf
End Sub
Public Function GetMeRegistry(ByVal RootKey As String) As String
txtRegistryDetail.Text=GetMeRegistry("HKEY_LOCAL_MACHINE\SOFTWARE\Classes\TypeLib\6.0\0\win32\Default")
End Function
Posted
Updated 31-Jul-16 23:14pm
v5
Comments
Richard MacCutchan 1-Aug-16 4:50am    
What happens in the GetMeRegistry subroutine?

1 solution

"Argument not optional error"
The error message is self explanatory: You define a method that takes two arguments:
VB.NET
Public Function GetMeRegistry(ByVal componentName As String, ByVal RootKey As String) As String
And you call it with only one:
VB
GetMeRegistry("ABC.OCX")
Either add the second parameter to the call, or remove it from the definition.
You probably also need to return a value from the function at some point...

But...You are lucky it doesn't compile, because it woudln't work:
VB.NET
Public Function GetMeRegistry(ByVal componentName As String, ByVal RootKey As String) As String
txtRegistryDetail.Text=GetMeRegistry("HKEY_...\Default")
End Function
All it does it call itself, so it'll crash with "out of stack space" pretty much immediately.
 
Share this answer
 
Comments
sheena k 1-Aug-16 5:23am    
yes correct but i want to search registry value using Root keyName. can u help me for reading key value in same
OriginalGriff 1-Aug-16 5:32am    
https://www.google.co.uk/search?q=read+from+registry+vb&oq=read+from+registry+vb&aqs=chrome..69i57j0l5.7631j0j7&sourceid=chrome&ie=UTF-8
Just follow a few links...
sheena k 1-Aug-16 6:59am    
Thanks :)
OriginalGriff 1-Aug-16 7:07am    
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900