I have a piece of vb.net code that I wrote. This is a for loop with two built-in if operations, and the compiler tells me that every elseif and endif should be preceded by an if match.
This is my second day working with vb.net ever, and the only programming experience I have is writing .bat files, so it can be something really stupid. But I can’t understand why I get these errors, and if you all want to help me, I would really appreciate it!
For Each computer In compArray If compArray(I) <> Computers.GetKey(I) Then notpresentList.Add(Computers.GetKey(I)) Else If Computers.GetByIndex(I) = 0 Then disabledList.Add(Computers.GetKey(I)) Elseif Computers.GetByIndex(I)=1 Then enabledList.Add(Computers.GetKey(I)) Elseif Computers.GetByIndex(I)=2 Then unknownList.Add(Computers.GetKey(I)) End if End if I += 1 Next
Context for this: I'm trying to write a piece of code that confirms the presence of a bit block. I wrote something in VBScript that would check if the blocker is turned on, and then send an email. This piece of code is part of a program that will extract these emails, compare them with a list of computers and then generate a digest email that indicates which computers are missing, enable or disable the beat blocker, or in an unknown state.
I am sure that there is also a better way to do this, but, as I said, I am pretty new to this, and we need to do this for legal reasons.
Thanks again!
EDIT: If you need more information, please ask me!
source share