hello guys, i'm just fooling around with vb 2008, and i thought i'd try to make a simple anti virus. my problem is that it only detects and deletes one of the files, i know it's because i use else if, but i don't know what else to use ?

if i put a steal.exe in my C drive it deletes it, if i put a hack.exe in my C drive it deletes it, but it wont delete both at the same time, so i just want to know what to use instead of else if?

Dim fiFile As New System.IO.FileInfo("C:\Steal.exe")
            Dim fiFile1 As New System.IO.FileInfo("C:\Virus.exe")
            If fiFile.Exists Then
                Virus.Items.Add("Stealer Detected (C:\Steal.exe)")
                Label1.Text = "Status : Deleting"
                Virus.Items.Add("Stealer Deleted (C:\Steal.exe)")
                Label1.Text = "Status : Finished"
            ElseIf fiFile1.Exists Then
                Virus.Items.Add("Hack Detected (C:\Virus.exe)")
                Label1.Text = "Status : Deleting"
                Virus.Items.Add("Hack Deleted (C:\Virus.exe)")
                Label1.Text = "Status : Finished"

Edited by SaintDK: n/a

8 Years
Discussion Span
Last Post by SaintDK

if elseif elseif elseif elseif elseif else
only ever runs ONE of the available choices. As soon as one of the if statements is true, that's all there is.

Try a sequence of separate if statements.


i already tried separating if statements.. :/ and what's a sequence?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.