Click here to Skip to main content
15,886,689 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hello,

I have the following code:

VB
Option Explicit

Const HKEY_CURRENT_USER = &H80000001 'HKEY_CURRENT_USER

Dim oReg
Dim strComputer,strValueName,arrValueNames
Dim strKeyPath1

Dim SyncMode5NameExists

ssig="Unable to open registry key"
strComputer = "."

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")

strKeyPath1 = "Software\Microsoft\Windows\CurrentVersion\Internet Settings"
oReg.EnumValues HKEY_CURRENT_USER,strKeyPath1,arrValueNames
For Each strValueName In arrValueNames
	SyncMode5NameExists = (StrComp(strValueName,"SyncMode5"))
	If SyncMode5NameExists != 0 Then
		Wscript.Echo "bla,bla"	
	End If
	'Exit For
Next

But, I get the following error, no idea what it is.
C:\scripts\test.vbs(20, 26) Microsoft VBScript compilation error: Expected ')

Thanks for your help,
Posted

1 solution

VB
If SyncMode5NameExists != 0 Then


should be
VB
If SyncMode5NameExists <> 0 Then


That is the VB not equal sign.
 
Share this answer
 
v2
Comments
namerg 7-Feb-13 14:27pm    
Hmm, so why the " Not equal to != " does not work ?
Mike Meinz 7-Feb-13 14:53pm    
The VBScript documentation says that != is not a valid VBScript comparison operator.

See Comparison Operators (VBScript)
bbirajdar 7-Feb-13 15:01pm    
Nice catch.. +5
Sergey Alexandrovich Kryukov 7-Feb-13 18:42pm    
Captain Obvious at work. My 5! :-)
—SA

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