我是VBS的新手,我正在尝试在Windows中开始UAC -A意愿去做,反过来,学习。
我不明白为什么我总是在最后一个结束符之前得到一个语法错误,如果
如果你能帮忙,我将不胜感激!
CurPass = ReadIni("C:\Program Files\User Account Control\ident.ini", "pass", "pass")
InpPass = inputbox("Please enter your current password:")
If InpPass = CurPass Then
NewPass = inputbox("Please enter your new password")
if NewPass=CurPass Then
KpPass=msgbox("Your new password is the same as your old password. Keep old password?",4+32,"UAC")
if KpPass=7 Then MsgBox("Please try again")
end if
Else
RNewPass = inputbox("Please re-enter your new password")
end if
if RNewPass=NewPass then
WriteIni "C:\Program Files\User Account Control\ident.ini", "pass", "Pass", NewPass
else msgbox("Your new passwords do not match. Try again.")
end If
else msgbox("Incorrect password")
End if发布于 2012-11-05 03:02:13
没有如果..。那就是你最后的..。结束If。如果你使用了适当的缩进,这一点马上就会显现出来。
更新:上述诊断错误。
我认为你想要这样的结构:
CurPass = ""
InpPass = ""
If InpPass = CurPass Then
NewPass = ""
If NewPass = CurPass Then
KpPass = ""
If KpPass = "7" Then
KpPass = "4711"
End If
Else
RNewPass = ""
End If
If RNewPass = NewPass Then
RNewPass = "xx"
Else
RNewPass = "yy"
End If
Else
CurPass = "whatamess"
End If然后VBScript迷失了方向,当你写道:
if KpPass=7 Then MsgBox("Please try again")
end if你可以有这样的“短if”
If Condition Then OneStatementAction但是,不应该有End If。这有点像在其他类似C语言中为单行/语句条件语句省略{}。那就是:最好避免。
发布于 2013-12-29 21:33:34
End IF是一个表达式,它告诉VB.NET你已经完成了你的条件。
每个IF都可能以一个IF结尾。
所以你的代码可能是这样的:
If textbox1.text = "Cat" Then
Do something
Else
Do not do that thing
End If再次检查您的代码,避免编写End IFs和elses look:
If textbox1.text = "Cat" Then
Do something
End IF
Else
Do not do that thing
End If//这不会起作用!在一个条件下,你不能有多个:
这是incorect:
IF something Then
IF blabla bla then
Else
Endif请看这里的链接,您可以在这里学习如何使用:http://msdn.microsoft.com/en-us/library/752y8abs.aspx
https://stackoverflow.com/questions/13221605
复制相似问题