Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vbscript VBS如果还有其他_Vbscript - Fatal编程技术网

Vbscript VBS如果还有其他

Vbscript VBS如果还有其他,vbscript,Vbscript,我是VBS新手,我正在尝试在Windows中启动UAC——这是一种做事的意志,反过来也是一种学习的意志 我不明白为什么我总是在最后一个结尾之前得到一个语法错误 如果你能帮忙,我将不胜感激 CurPass = ReadIni("C:\Program Files\User Account Control\ident.ini", "pass", "pass") InpPass = inputbox("Please enter your current password:") If InpPass =

我是VBS新手,我正在尝试在Windows中启动UAC——这是一种做事的意志,反过来也是一种学习的意志

我不明白为什么我总是在最后一个结尾之前得到一个语法错误

如果你能帮忙,我将不胜感激

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

如果。。那么最后一次。。结束如果。如果您使用了适当的缩进,这将立即变得显而易见

更新:上述诊断错误。

我想你想要这个结构:

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 Condition Then OneStatementAction

但是如果,那么就不应该有
结束。这有点像在其他类似C语言中省略单行/语句条件的{}。也就是说:最好避免。

End IF是告诉VB.NET您完成了条件的表达式

每一个IF都可以结束,如果

因此,您的代码可能如下所示:

If textbox1.text = "Cat" Then

   Do something
Else
   Do not do that thing
End If
再次检查代码,避免编写End IFs,然后再编写ELSE:

If textbox1.text = "Cat" Then

   Do something
End IF

Else
   Do not do that thing
End If
//这行不通!如果在一个条件中,则不能有多个:

这是不正确的:

IF something Then
  IF blabla bla then
Else
Endif
请参阅此处的链接,从中您可以了解如何使用therse:

oops,我的失败,但理解IF和ENd IF的规则是一样的