|
-
May 31st, 2016, 06:04 PM
#1
Thread Starter
New Member
Syntax error
I have written the sub Below but when I call RegSetStr in a sub below
I get a request from the compiler to use a "=" sign as if its a function
Whats not making it a sub (VB6)
Private Sub RegSetStr(ByRef FullLocation_Name As String, ByRef Str As String)
Dim oReg As Object
Set oReg = CreateObject("WScript.Shell")
oReg.RegWrite FullLocation_Name, Str, "REG_SZ"
Set oReg = Nothing
End Sub
Private Function GetWinReg(ByRef LocationName As String) As String
Dim Str As String
Dim Zeros As String
Dim BaseLoc As String
Zeros = "00000"
BaseLoc = "SOFTWARE\Microsoft\Windows\TestProgram"
RegCreateKey (BaseLoc)
GetWinReg = RegGetStr(BaseLoc & LocationName)
If Len(GetWinReg) < 1 Then
RegSetStr(BaseLoc & LocationName, Zeros) ???????? error = BaseLoc
GetWinReg = Zeros
End If
End Function
-
May 31st, 2016, 06:25 PM
#2
Re: Syntax error
remove the parenthesis ... just pass the parameters... when you put the () around then. VB thinks you're calling a function...
-tg
-
Jun 6th, 2016, 09:47 AM
#3
Re: Syntax error
Just to play Devil's Advocate (and because my VB code has to cohabit with lots of other, 'C'-style languages), I use the Call keyword, which forces the [consistent] use of braces:
Code:
If (Len(GetWinReg) < 1) Then
Call RegSetStr(BaseLoc & LocationName, Zeros)
GetWinReg = Zeros
End If
Warning: Whichever "style" you choose, stick to it!
Mixing and matching is a Bad Idea, especially when you start working with Object references:
Code:
SomeFunction (SomeObjectReference)
Note the slightly odd placement of that space before the opening brace and then, at run-time, "marvel" at how your object reference "magically" transforms into its own Default Property when it "arrives" inside the function being called. )
Regards, Phill W.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|