Skip to content
MPGHThe Dark Arts
/
RegisterLog in
Forum
Community
What's NewLatest posts across the boardTrendingHottest threads right nowSubscribedThreads you follow
Discussion
GeneralIntroductionsEntertainmentDebate FortFlaming & Rage
Board
News & AnnouncementsMPGH TimesSuggestions & HelpGiveaways
More Sections
Art & Graphic DesignProgrammingHackingCryptocurrency
Hacks & Cheats
Games
ValorantCS2 / CS:GOCall of Duty / WarzoneFortniteApex LegendsEscape From Tarkov
+14 moreLeague of LegendsGTA VMinecraftRustROTMGBattlefieldTroveBattleOnCombat ArmsCrossFireBlackshotRuneScapeDayZDead by Daylight
Resources
Game Hacking TutorialsReverse EngineeringGeneral Game HackingAnti-CheatConsole Game Hacking
Tools
Game Hacking ToolsTrainers & CheatsHack/Release NewsNew
Submit a release →Share your cheat, tool, or config with the community.
AINEW
AI Tools
General & DiscussionPrompt EngineeringLLM JailbreaksHotAI Agents & AutomationLocal / Open Models
AI × Gaming
AI Aimbots & VisionML Anti-CheatGame Bots & Automation
Create
AI Coding / Vibe CodingAI Art & MediaAI Voice & TTS
The AI frontier →Where game hacking meets modern machine learning. Jump in.
Marketplace
Buy & Sell
SellingBuyingTradingUser Services
Trust & Safety
Middleman LoungeMarketplace TalkVouch Copy Profiles
Money
Cryptocurrency TalkCurrency ExchangeWork & Job Offers
Start selling →List accounts, services, and goods. Use the middleman to trade safe.
MPGH The Dark Arts

A community for offensive security research, reverse engineering, and AI.

Community

ForumMarketplaceSearch

Account

RegisterLog in

Legal

Privacy PolicyForum RulesHelp & FAQ
© 2026 MPGH · All rights reserved.Built by the community, for the community. For educational purposes onlyContent is shared for security research and education — we don't condone illegal use. You're responsible for complying with applicable laws. Use at your own risk.
Home › Forum › Programming › Visual Basic Programming › How to delete files in Visual Basic with a CheckedListBox1

QuestionHow to delete files in Visual Basic with a CheckedListBox1

Posts 1–15 of 20 · Page 1 of 2
cruz967
cruz967
How to delete files in Visual Basic with a CheckedListBox1
Hello, I was wondering how I can make my form look for files in a directory (Let's say.. Combat Arms or something) And it'll look for.. let's say text files.. How can I have that text file (Or name I guess I can say) Go into the CheckedListBox1 (Example inside of CheckedListBox1 it says the text name and the directory:"C:\Game\Combat Arms\Filename.txt or .exe or .jpg etc. etc.") and I can check it and click the "Delete" button and it'll delete the file from the directory and it'll clear from the CheckedListBox1.. If you can help me I'll be more then thankful and more then just happy(: (Sorry if this was hard to understand.. I'm just very tired and in a hurry)
#1 · 13y ago
DA
DawgiiStylz
I wouldn't know how to do it with a ListBox, but with a ListView its a bit easier

Code:
For Each Item as ListViewItem in ListView1.CheckedIndicies
IO.File.Delete(Item.Text)
Next
#2 · 13y ago
abuckau907
abuckau907
He wants to know everything from "finding" the files, to adding them to the checkbox, to removing items from it. It's not 1 question, its a "please give me code which does ___ ___ & ____".

-And has 'no thoughts on how' to accomplish this -- he wants copy-pastable code.
#3 · edited 13y ago · 13y ago
Jorndel
Jorndel
Something Nobby I Made:


Design:
#4 · edited 13y ago · 13y ago
abuckau907
abuckau907
If there is an error, 'I' will not be increased, and an infinite loop will happen because the same index will be used in the next iteration: and fail, and loop. ?

Add 'Finally' block and move "I++" to that? or initialize 'I' to -1 and move "I++" before the function call. ?

Even if it didn't loop forever,on error 'I' won't be incremented, so 'I' won't correctly correspond to the next item in the list.
#5 · edited 13y ago · 13y ago
Jorndel
Jorndel
Quote Originally Posted by abuckau907 View Post
If there is an error, 'I' will not be increased, and an infinite loop will happen because the same index will be used in the next iteration:
The For Each will still be done, and ignore the item that have the problem.
-But I see your point about the "never-ending-problem-file"

Well, this is such things I never code so

+ Quit
#6 · 13y ago
abuckau907
abuckau907
Yep, not sure what I was thinking: it won't infinite loop, but 'I' is still not incremented as it should.
#7 · 13y ago
Jorndel
Jorndel
Quote Originally Posted by abuckau907 View Post
Yep, not sure what I was thinking: it won't infinite loop, but 'I' is still not incremented as it should.
Tip:
Add the I += 1 BEFORE the File Delete Operation

X,x
(Was thinking C# i++ )
#8 · 13y ago
abuckau907
abuckau907
I forget if .SelectedItems () is 0 or 1 based (intellisense will tell you) : if it's 0 based, and you move I++ before the function call, you must initialize I to -1 or you'll skip item (0). If it's 1 based, initialize it to 0.
#9 · 13y ago
Jorndel
Jorndel
Quote Originally Posted by abuckau907 View Post
I forget if .SelectedItems () is 0 or 1 based (intellisense will tell you) : if it's 0 based, and you move I++ before the function call, you must initialize I to -1 or you'll skip item (0). If it's 1 based, initialize it to 0.
As it's an Array Based Function: 0
#10 · 13y ago
abuckau907
abuckau907
Quote Originally Posted by Jorndel View Post


Tip:
Add the I += 1 BEFORE the File Delete Operation

X,x
(Was thinking C# i++ )
And initialize I to -1, or you'll skip the first item in the list : p


....there are still 1 based "array function" ...mostly dealing with Strings.
#11 · 13y ago
Jorndel
Jorndel
Quote Originally Posted by abuckau907 View Post
And initialize I to -1, or you'll skip the first item in the list : p


....there are still 1 based "array function" ...mostly dealing with Strings.
I've never ever in my life heard of arrays starting with an index of 1
#12 · 13y ago
abuckau907
abuckau907
I'm drawing a blank...I'll post when I can think of one. I think it's weird too.

-Something to do with indexed properties, some start at 1.

Edit:

http://msdn.microsof*****m/en-us/library/ms233801.aspx

Only example it gives is the Mid function, which has been replaced by String.SubString() : I can't think of any others at the moment so I guess it's a dumb argument. I agree, it's silly. I think I've only seen it with functions that return string/ array of strings.


^^It specifically says 0-based because sometimes it's not.

^^That's vb for you : still some quirks, backwards compatibility I guess. I tend to check intellisense when using strings functions, I vaguely remember a few more doing the same thing.
#13 · edited 13y ago · 13y ago
cruz967
cruz967
@Jorndel thanks for the post mate.. But question.. How can I have certain files to show? (Like let's say I was making a Combat Arms cleaner.. How can I make it just show *.txt files or.. EndingBanner.exe etc.)
#14 · 13y ago
Jorndel
Jorndel
Quote Originally Posted by cruz967 View Post
@Jorndel thanks for the post mate.. But question.. How can I have certain files to show? (Like let's say I was making a Combat Arms cleaner.. How can I make it just show *.txt files or.. EndingBanner.exe etc.)
at the end here:

#15 · edited 13y ago · 13y ago
Posts 1–15 of 20 · Page 1 of 2

Post a Reply

Similar Threads

  • How to put hotkey in visual basic with screen shots !By Legendary Ghost in Programming Tutorials
    2Last post 11y ago
  • how to make injector for visual basic expressBy frekesh1 in Programming Tutorials
    2Last post 13y ago
  • How to: Move a File in Visual BasicBy Pixie in Visual Basic Programming
    12Last post 17y ago
  • [TUT] How to Print Text in Visual BasicBy Mr. Jingles in Visual Basic Programming
    0Last post 17y ago
  • Making A Batch File In Visual BasicBy condor01 in Visual Basic Programming
    0Last post 18y ago

Tags for this Thread

None