I'm getting a compile error for this code:
Public Sub CommandButton1_Click()
If TextBox1.Text = "log off" Then
Shell "cmd.exe /c shutdown -l", vbHide: TextBox2.Text = "Logging off"
If TextBox1.Text = "shutdown" Then
Shell "cmd.exe /c shutdown -s", vbHide: TextBox2.Text = "Shutting Down"
If TextBox1.Text = "restart" Then
Shell "cmd.exe /c shutdown -r", vbHide: TextBox2.Text = "Restarting"
Else
MsgBox "Command Not Defined",vbCritical
End Sub
Now it comes up with this Error Message of "Block If without End If". Why?
IFstatement by putting the condition and result in one line. the lastElseis floating since allIFstatements above already terminated. @simoco already showed the alternative.