I am writing a fake antivirus software, of course as a prank, not for MONEY. The code as follows:

'ImageList, 0 Low 1 Averaga 2 High
        If ProgressBar1.Value = 10000 Then
            Label4.Text = ("Scan was finished at " & My.Computer.Clock.GmtTime.ToString & ".")
            MsgBox(ListView1.Items.Count & " threats were detected on your PC! We recommend you remove them immediately after reviewing them.", MsgBoxStyle.Exclamation, "E-Secure Lite")
            Button1.Enabled = True
            Button2.Enabled = True
            Button3.Enabled = True
            Button10.Enabled = True
            Timer1.Enabled = False
        ElseIf ProgressBar1.Value = 0 Then
            Label4.Text = ("Loading database...")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 1 Then
            Label4.Text = ("Checking for Urchin trojan...")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 2 Then
            'Start adding items
            ListView1.Update()
            ListView1.HeaderStyle.Equals(100)
            ListView1.Items.Insert(0, "Trojan.Urchin.ds!x", 2)
            ListView1.Items(0).SubItems.Add("C:\Program Files\SeeYouClick\syc.exe")
            ListView1.Items(0).SubItems.Add("High")
            ListView1.Items(0).UseItemStyleForSubItems.Equals(True)
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 3 Then
            ListView1.Items.Insert(1, "Trojan.Urchin.d", 2)
            ListView1.Items(1).SubItems.Add("C:\Program Files\SeeYouClick\syc.dll")
            ListView1.Items(1).SubItems.Add("High")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 5 Then
            ListView1.Items.Insert(2, "Trojan.Urchin.a", 2)
            ListView1.Items(2).SubItems.Add("C:\Program Files\SeeYouClick\toolz.dll")
            ListView1.Items(2).SubItems.Add("High")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 6 Then
            ListView1.Items.Insert(3, "Trojan.Urchin.lnd", 2)
            ListView1.Items(3).SubItems.Add("C:\Program Files\SeeYouClick\lang.zip")
            ListView1.Items(3).SubItems.Add("High")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 24 Then
            Label4.Text = ("Checking for SmileCentral adware...")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 26 Then
            ListView1.Items.Insert(4, "SmileCentralExplorer", 0)
            ListView1.Items(4).SubItems.Add("C:\WINDOWS\myexplorer.exe")
            ListView1.Items(4).SubItems.Add("Low")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 39 Then
            ListView1.Items.Insert(5, "SmileCentral", 0)
            ListView1.Items(5).SubItems.Add("C:\WINDOWS\system32\smilecentral.ocx")
            ListView1.Items(5).SubItems.Add("Low")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 40 Then
            Label4.Text = ("Checking for SpyBooster...")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 53 Then
            ListView1.Items.Insert(6, "SpyBooster", 2)
            ListView1.Items(6).SubItems.Add("C:\ProgramData\sb\a2eFzyOLcL.exe")
            ListView1.Items(6).SubItems.Add("High")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 73 Then
            ListView1.Items.Insert(7, "SpyBooster.c", 2)
            ListView1.Items(7).SubItems.Add("C:\config.bin")
            ListView1.Items(7).SubItems.Add("High")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 100 Then
            Label4.Text = ("Checking for MyInfo4U adware...")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 154 Then
            Label4.Text = ("Checking for system32 and New folder worm...")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 201 Then
            Label4.Text = ("Checking for Renos trojan...")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 208 Then
            ListView1.Items.Insert(8, "Trojan.Renos", 2)
            ListView1.Items(8).SubItems.Add("C:\WINDOWS\Temp\3VXk4uMCrxEulEgNAGyA\tmp503313.TMP")
            ListView1.Items(8).SubItems.Add("High")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 210 Then
            ListView1.Items.Insert(9, "Trojan.Renos", 2)
            ListView1.Items(9).SubItems.Add("C:\WINDOWS\Temp\3VXk4uMCrxEulEgNAGyA\tmp741174.TMP")
            ListView1.Items(9).SubItems.Add("High")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 216 Then
            ListView1.Items.Insert(10, "Trojan.Renos", 2)
            ListView1.Items(10).SubItems.Add("C:\WINDOWS\Temp\3VXk4uMCrxEulEgNAGyA\tmp001021.TMP")
            ListView1.Items(10).SubItems.Add("High")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 220 Then
            ListView1.Items.Insert(11, "Trojan.Renos", 2)
            ListView1.Items(11).SubItems.Add("C:\WINDOWS\Temp\3VXk4uMCrxEulEgNAGyA\tmp987121.TMP")
            ListView1.Items(11).SubItems.Add("High")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 221 Then
            ListView1.Items.Insert(12, "Trojan.Renos", 2)
            ListView1.Items(12).SubItems.Add("C:\WINDOWS\Temp\3VXk4uMCrxEulEgNAGyA\tmp444440.TMP")
            ListView1.Items(12).SubItems.Add("High")
            ProgressBar1.Value = ProgressBar1.Value + 1
            'Begin FileSystem scan, use random file names
        ElseIf ProgressBar1.Value = 264 Then
            Label4.Text = ("Scanning file system...")
            Timer2.Enabled = True
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 268 Then
            ListView1.Items.Insert(13, "Trojan.MalicousSource", 1)
            ListView1.Items(13).SubItems.Add("C:\WINDOWS\system32\Drivers\etc\hosts")
            ListView1.Items(13).SubItems.Add("Average")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 312 Then
            ListView1.Items.Insert(14, "Trojan.Booster", 2)
            ListView1.Items(14).SubItems.Add("C:\WINDOWS\system\boostur.sys")
            ListView1.Items(14).SubItems.Add("High")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 325 Then
            ListView1.Items.Insert(15, "Trojan.ILOVEYOU", 0)
            ListView1.Items(15).SubItems.Add("C:\ProgramData\manman.exe")
            ListView1.Items(15).SubItems.Add("Low")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 346 Then
            ListView1.Items.Insert(16, "Worm.ILOVEYOU", 2)
            ListView1.Items(16).SubItems.Add("C:\ProgramData\autorrun\text.vbs")
            ListView1.Items(16).SubItems.Add("High")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 362 Then
            ListView1.Items.Insert(17, "Trojan.Downloader.geremall", 2)
            ListView1.Items(17).SubItems.Add("C:\Program Files\folder.exe")
            ListView1.Items(17).SubItems.Add("High")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 390 Then
            ListView1.Items.Insert(18, "Worm.BlastIt", 1)
            ListView1.Items(18).SubItems.Add("C:\autoexec.bat")
            ListView1.Items(18).SubItems.Add("Average")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 423 Then
            ListView1.Items.Insert(19, "DOS.DiskEraser", 2)
            ListView1.Items(19).SubItems.Add("C:\WINDOWS\system32\addons\msimportant.bat")
            ListView1.Items(19).SubItems.Add("High")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 444 Then
            ListView1.Items.Insert(20, "DOS.DiskEraser", 2)
            ListView1.Items(20).SubItems.Add("C:\WINDOWS\system32\addons\dos\batch")
            ListView1.Items(20).SubItems.Add("High")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 496 Then
            ListView1.Items.Insert(21, "DOS.DiskEraser", 2)
            ListView1.Items(21).SubItems.Add("C:\WINDOWS\system32\addons\miero\soft\32.bat")
            ListView1.Items(21).SubItems.Add("High")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 510 Then
            ListView1.Items.Insert(22, "DOS.Slump", 2)
            ListView1.Items(22).SubItems.Add("C:\ProgramData\ssueebq\Microsoft\server.cmd")
            ListView1.Items(22).SubItems.Add("High")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 522 Then
            ListView1.Items.Insert(23, "DOS.Slump", 2)
            ListView1.Items(23).SubItems.Add("C:\ProgramData\ssueebq\Microsoft\server")
            ListView1.Items(23).SubItems.Add("High")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 533 Then
            ListView1.Items.Insert(24, "DOS.Slump.Installer", 2)
            ListView1.Items(24).SubItems.Add("C:\ProgramData\ssueebq\Microsoft\Microsoft.exe")
            ListView1.Items(24).SubItems.Add("High")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 597 Then
            ListView1.Items.Insert(25, "Spyware.AdvSpyCam", 2)
            ListView1.Items(25).SubItems.Add("C:\ProgramData\Microsoft\asc.dll")
            ListView1.Items(25).SubItems.Add("High")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 600 Then
            ListView1.Items.Insert(26, "Spyware.AdvSpyCam", 2)
            ListView1.Items(26).SubItems.Add("C:\ProgramData\Microsoft\asc.sys")
            ListView1.Items(26).SubItems.Add("High")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 620 Then
            ListView1.Items.Insert(27, "Spyware.AdvSpyCam", 2)
            ListView1.Items(27).SubItems.Add("C:\ProgramData\Microsoft\asc.pqr")
            ListView1.Items(27).SubItems.Add("High")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 651 Then
            ListView1.Items.Insert(28, "Trojan.not-a-virus.JokeProgram.Joker", 0)
            ListView1.Items(28).SubItems.Add("C:\WINDOWS\joker.exe")
            ListView1.Items(28).SubItems.Add("Low")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 700 Then
            ListView1.Items.Insert(29, "Trojan.BMP.Vul", 0)
            ListView1.Items(29).SubItems.Add("C:\WINDOWS\joker_msg.bmp")
            ListView1.Items(29).SubItems.Add("Low")
            ListView1.Refresh()
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 651 Then
            ListView1.Items.Insert(30, "Trojan.McAfee", 1)
            ListView1.Items(30).SubItems.Add("C:\mcafee.exe")
            ListView1.Items(30).SubItems.Add("Average")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 689 Then
            ListView1.Refresh()
            ListView1.Update()
            'ArguementOutOfRange Error
            ListView1.Items.Insert(31, "Trojan.Norton", 1)
            ListView1.Items(31).SubItems.Add("C:\norton.exe")
            ListView1.Items(31).SubItems.Add("Average")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 701 Then
            ListView1.Items.Insert(32, "Trojan.Norton", 1)
            ListView1.Items(32).SubItems.Add("C:\ccsvchst.exe")
            ListView1.Items(32).SubItems.Add("Average")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 711 Then
            ListView1.Items.Insert("Trojan.EwVirus.t", 1)
            ListView1.Items(33).SubItems.Add("C:\norton\av_pack.exe")
            ListView1.Items(33).SubItems.Add("Average")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 765 Then
            ListView1.Items.Insert("Worm.SluiVirus", 2)
            ListView1.Items(34).SubItems.Add("C:\WINDOWS\system32\defset.vbs")
            ListView1.Items(34).SubItems.Add("High")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 802 Then
            ListView1.Items.Insert("Worm.System.d", 1)
            ListView1.Items(35).SubItems.Add("C:\WINDOWS\system32\slui32.vbs")
            ListView1.Items(35).SubItems.Add("Average")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 820 Then
            ListView1.Items.Insert("Unknown Trojan.Autorun", 2)
            ListView1.Items(36).SubItems.Add("")
            ListView1.Items(36).SubItems.Add("High")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 830 Then
            ListView1.Items.Insert("Unknown Trojan.Autorun", 2)
            ListView1.Items(37).SubItems.Add("")
            ListView1.Items(37).SubItems.Add("High")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 840 Then
            ListView1.Items.Insert("Unknown Trojan.Runmeonce", 2)
            ListView1.Items(38).SubItems.Add("")
            ListView1.Items(38).SubItems.Add("High")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 850 Then
            Label4.Text = ("Checking for tracking cookies...")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 865 Then
            ListView1.Items.Insert("http://tracker.google.com/", 2)
            ListView1.Items(39).SubItems.Add("")
            ListView1.Items(39).SubItems.Add("High")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 872 Then
            ListView1.Items.Insert("http://ftp.goldads2011.com/", 2)
            ListView1.Items(40).SubItems.Add("")
            ListView1.Items(40).SubItems.Add("High")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 888 Then
            ListView1.Items.Insert("http://myweb.itadvertise.org/", 2)
            ListView1.Items(41).SubItems.Add("")
            ListView1.Items(41).SubItems.Add("High")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 890 Then
            ListView1.Items.Insert("http://ftp.infinityads.com/", 2)
            ListView1.Items(42).SubItems.Add("")
            ListView1.Items(42).SubItems.Add("High")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 888 Then
            ListView1.Items.Insert("http://www.seriousads.com/", 2)
            ListView1.Items(43).SubItems.Add("")
            ListView1.Items(43).SubItems.Add("High")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 900 Then
            ListView1.Items.Insert("http://www.clickads2010.com/", 2)
            ListView1.Items(44).SubItems.Add("")
            ListView1.Items(44).SubItems.Add("High")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 923 Then
            ListView1.Items.Insert("http://www.adserveryours.com/", 2)
            ListView1.Items(45).SubItems.Add("")
            ListView1.Items(45).SubItems.Add("High")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 946 Then
            ListView1.Items.Insert("http://www.mailservice.net.", 2)
            ListView1.Items(46).SubItems.Add("")
            ListView1.Items(46).SubItems.Add("High")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 950 Then
            ListView1.Items.Insert("http://liveupdate.norton.com/", 2)
            ListView1.Items(47).SubItems.Add("")
            ListView1.Items(47).SubItems.Add("High")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 961 Then
            ListView1.Items.Insert("http://www.bearshare.com/", 2)
            ListView1.Items(48).SubItems.Add("")
            ListView1.Items(48).SubItems.Add("High")
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 968 Then
            ListView1.Items.Insert("http://www.kazaaserver.com/", 2)
            ListView1.Items(49).SubItems.Add("")
            ListView1.Items(49).SubItems.Add("High")
            ListView1.EndUpdate()
            ProgressBar1.Value = ProgressBar1.Value + 1
        ElseIf ProgressBar1.Value = 999 Then
            Label4.Text = ("Removing temporary database files...")
            ProgressBar1.Value = ProgressBar1.Value + 1
        Else
            ProgressBar1.Value = ProgressBar1.Value + 1
        End If
    End Sub

has a problem in this line: ListView1.Items.Insert(31, "Trojan.Norton", 1) has the ArguementOutOfRangeException error:

InvalidArgument=Value of '31' is not valid for 'index'.
Parameter name: index

Please help! I am stuck here and no other website provided information for me that is useful.

This error happens when the index parameter is less than 0 or greater than the value of the Count property of the ListView.ListViewItemCollection.

To avoid this problem, use the Add method to insert the item in the last position or use the index 0 to inset always int he first one.

If you want to insert at an specific position, then be sure that there are enough items in the ListViewItemCollection and that the position index is less than the Count property.

Hope this helps

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.