r/visualbasic • u/Pleasant_Chef3798 • Feb 05 '21
r/visualbasic • u/SaladSilent5342 • Oct 14 '26
HoneyVB (RetroVB6) progress update: running classic applications and games in the browser, with cross-platform builds
Hi again, r/dotnet! Some of you may remember my earlier posts about HoneyVB (RetroVB6), my project built around C# and ASP.NET Core to bring legacy software onto modern platforms.



For anyone who missed them:
The project has continued to grow, and I wanted to share where it is today.
HoneyVB is a browser-based development environment with a familiar VB6-style IDE, visual form design, code editing, debugging, and browser execution. You can import supported VB6 projects, inspect their forms and modules, and continue developing with the original code.
What can HoneyVB run? Here are some examples. The accompanying video shows a selection of them; Reddit’s upload limits mean I can’t fit all the recordings into this post.
Microsoft Word for Windows 1.1a — an early Windows version of Microsoft Word.
Adobe Photoshop, from the 1.0.1 source release — the classic Macintosh image editor.
Wolfenstein: Enemy Territory — the classic multiplayer first-person shooter.
Waite Group Flight Simulator (FSIM 2.1) — the DOS-era C++ flight simulator from Building Your Own Flight Sim in C++, with roots in Flights of Fantasy.
HeidiSQL — the database management application.
eMule — the peer-to-peer file-sharing client.
Notepad++ — the code and text editor.
kys-pascal — a Pascal remake of Heroes of Jin Yong.
sdl-pascal — a Pascal/SDL sample project.
ScePSX — a PlayStation emulator written in C#.
SnailsXNA — Snails, an XNA-based puzzle-platformer.
These are just some of the applications and games running in HoneyVB, and not every example listed above appears in this video. The footage shows selected workflows and interactions, rather than complete compatibility with every feature of each application.
I’m also currently testing SharpDevelop, wxDev-C++, Lazarus, and Shareaza in HoneyVB to evaluate compatibility and identify what still needs work. These projects are undergoing validation—stay tuned for more demos and progress updates!
The VB6 compatibility work covers technologies that many real applications depend on:
Crystal Reports: compatibility for CrystalReport, CRViewer, and reporting APIs, including data-driven reports, grouping, summaries, pagination, printing, and export. Portable reporting works across platforms; preserving the original layout of
.rptfiles uses an optional Windows host with a compatible Crystal Reports runtime.DirectX 7, 8, and 9: compatibility layers for supported graphics and multimedia features, including mapping legacy Direct3D rendering to WebGL so supported VB6 games and graphics applications can run in a browser.
Serial communication and hardware simulation: RS-232/COM port support through an MSComm-compatible layer, including loopback simulation for testing without physical hardware. It supports communication buffers, binary data, and receive/send events, with connections to real serial devices through Web Serial where available and authorized by the user.
Beyond VB6, HoneyVB uses a plugin architecture to integrate other languages, frameworks, and development environments. Its language coverage and ongoing integration work include:
DOS BASIC and modern descendants: QBasic, QuickBASIC 4.x, GW-BASIC/BASICA, and QB64.
Classic home-computer BASICs: Applesoft BASIC, Apple Integer BASIC, Commodore BASIC, Sinclair BASIC, Atari BASIC, BBC BASIC, MSX-BASIC, Locomotive BASIC, TRS-80 Level I BASIC, TRS-80 Level II BASIC, and TRS-80 Color BASIC.
Pascal: Delphi/Object Pascal, Free Pascal/Lazarus, and Apple MPW Object Pascal.
C/C++: native C/C++ projects, Visual C++ 6/MFC, C++Builder 6/VCL, wxWidgets, Win16 C, and DOS 32-bit C projects using Watcom/DOS4GW.
Lua: embedded Lua scripts in supported C/C++ host projects.
.NET: C# and VB.NET, with integrations and ongoing compatibility work spanning .NET Framework/WinForms, WPF, Silverlight, Windows Phone, and XNA.
Business and scientific languages: Visual FoxPro, COBOL, Fortran, and PowerBuilder/PowerScript.
Assembly: DOS x86/FASM projects, plus MASM/TASM and Motorola 68K assembly handling within relevant project pipelines.
Flash/ActionScript: importing legacy Flash content and converting supported projects into HTML5 for browser execution.
Support varies across these integrations. Some include browser execution, while others currently focus on importing, analysis, editing, or resource previews. PowerBuilder, for example, currently provides project analysis and Window/DataWindow previews.
HoneyVB also provides build and export targets for Windows, macOS, Linux, Android, and iOS. Supported applications can be packaged with their browser runtime inside desktop or mobile shells. iOS device deployment uses an exported Xcode project that you sign with your own developer credentials.
One feature I’m especially excited about is running compiled VB6 applications without their source code. You can upload a supported VB6 executable and run it inside HoneyVB through its binary execution layer. Required runtime files and DLL/OCX dependencies still matter, but this creates possibilities for applications whose source has been lost.
I’m also actively developing native compilation for VB6, targeting Windows PE, macOS Mach-O, and Linux ELF executables. That work is underway, with the goal of compiling supported VB6 projects into native machine code for all three desktop platforms.
Compatibility is still evolving. I’m testing against original projects and improving the shared language and runtime implementations as issues appear. The goal is to make older software easier to explore, maintain, and keep using—from business applications and reporting tools to games and programs that communicate with hardware.
Thanks to everyone who commented on the earlier posts, and to the developers and preservation projects that made these historical sources available for study.
What legacy application or game would you bring back—especially if all you have left is the executable?
All third-party product names, trademarks, copyrights, and other intellectual property mentioned above belong to their respective owners. HoneyVB is intended for research and educational purposes.
HoneyVB reserves the right to offer different levels of functionality across releases and editions. The capabilities described above do not guarantee that all features will be available simultaneously or in every version. Language integrations, DirectX support, and other compatibility features may be introduced gradually, limited, or temporarily unavailable.
r/visualbasic • u/mika • Jul 10 '26
VB6 Editor Modernizer addin
Hey people, I still need to work in VB6 now and then and I got frustrated with the editor being so old fashioned. I missed a lot of the functionality from the newer Visual Studios.
Anyway I used Claude Fable to create an addon for VB6 to update and modernize the editor with some nice new features like a much nicer find and replace and text highlighter, text manipulation shortcuts like moving lines up and down, commenting blocks, some light git integration, etc...
Anyway, I know there's not many of us that have to actually still work in VB6, but if you're one of us you might like this.
r/visualbasic • u/lagrangersf • Jun 11 '26
Why do my VB6 programs keep getting detected as malware?
I know VB6 is old, but the fact that Windows 11 still includes the runtimes necessary to run programs written in VB6 makes it still useful. That, and it's a lot simpler for me to use than the .NET flavor of VB (not to mention, programs written in VB6 are not bloated like .NET).
That said, more often than not, even the simplest programs I write in VB6 end up being detected as malware. For example, I created a "scratch pad" program solely for my own personal use. It's pretty much just a single text window that functions as a persistent memo pad. I type notes into it, then it automatically saves them to a .txt file located in the user's TEMP folder. Then, whenever it is closed and re-opened, it automatically reloads the contents of that .txt file and displays it. It is 100% harmless, a simple program whose sole purpose in life is to open and save a single text file just to display notes and memos. Yet the instant I compiled the EXE, Windows Security threw a major fit, deleted it, and said that it was a trojan that "executes commands from an attacker".
This happens with pretty much every VB6 project I create, and needless to say, it's getting quite bothersome. So...other than having to put antivirus exclusions for every single project I create (which can be annoying since I have multiple computers I tend to use them on)...why is Windows Security so adamant that anything created in VB6 is automatically malicious? And is there anything I can do with the projects themselves to mitigate this?
Thank you.
UPDATE 6/12: Following a recommendation, I changed the text file storage location from TEMP to AppData, and made a few other minor tweaks to the code (i.e. removing the "magic numbers" from the CTRL+A subroutines). I dunno if it was that, or something else entirely, but now when I compile the EXE, Windows Defender leaves it alone and it runs perfectly fine. Someone mentioned the antivirus detections that end in "ml" as being AI-based, and indeed that's what it was being detected as before. So maybe the AI detection was changed too, and now it's not tripping up on the compiled EXE (don't have the original version to test this anymore though).
That said, it still gets five hits as malware according to VirusTotal ( https://www.virustotal.com/gui/file/17e49d12080e555239c94c8a34fe38f54dceba63d8dbe72a09ab26aa85782ee1 ), but I imagine 100% elimination of false positives is impossible, especially with AI slop being used to detect malware now.
r/visualbasic • u/_v3nd3tt4 • Dec 01 '24
Using VB.NET gets you insulted by Microsoft
I was recently searching for something and found a great article on something related. While reading the comments I found some guy berating, insulting a belittling the article author for using VB.NET. While i currently use c#, i learned .NET using VB, and still like VB. And while I hate Java (from experience using it years ago), I can't imagine myself insulting someone who chooses to use Java. So I was pretty surprised and upset when I saw the comments from that guy, and even more upset when I learned he's a Senior at Microsoft for the past 8 years or so. As a fan of most Microsoft products and focused almost exclusively on the .NET framework and ecosystem, this hit me in a really sour spot. I personally feel developers are usually of a fact driven mindset, and are part of rather small communities in which many are contributors to. I feel these contributors should be thanked for giving without asking in return, and not bullied online. I just wanted to share my thoughts and what prompted my thoughts (see video below). And while my title may be a little misleading, employees of the major companies/players in our industry should be held to a slightly higher standard, in my opinion.
r/visualbasic • u/thudly • Sep 04 '22
VB.NET Help Has anybody figured out a fix for this that actually works? Visual Studio is basically useless at this point.
r/visualbasic • u/FriendlyKush • Apr 05 '18
I'm so happy right now, this is why i love programming.
I finally got my program to work in the morning after a long sleepless night. I have to say the feeling you get when it finally works is something special :)
Edit: I'm now stuck on something else. Hate my life.
r/visualbasic • u/ShadowTzu • Mar 16 '26
This isn't a Rubik's Cube, it's a million cubes in Visual Basic
r/visualbasic • u/K2H_Dev • Nov 27 '24
Article My VB.NET 2D MMORPG Is Finally Complete!
Key To Heaven is my VB.Net passion project, a 2D MMORPG that I’ve been working on for almost 20 years. After years of dedication, I’m thrilled to announce that the game is finally complete and ready to launch!
Mark your calendars: on November 29th at 20:00 CET, the game will officially leave Early Access on Steam. Everyone will start fresh at level 1, embarking on this journey together. For me, this marks the beginning of some peace of mind, allowing me to shift my focus to smaller patches.
What’s it made in?
The game is built entirely in VB.NET.
The client runs on .NET 4.0 for compatibility with lower-end systems.
The server uses .NET 5.0. While I could upgrade to .NET 8, the current setup perfectly suits the project’s needs.
For graphics, I’ve relied on SFML, which has been a great fit for creating the retro aesthetic I envisioned.
Server Architecture
The server system is designed with flexibility in mind:
Each Realm can connect multiple servers, so, for example, I can host a server in both the US and EU, both syncing with the same database and master server.
This setup lets players seamlessly switch between servers to play with friends across regions, utilizing the same account & characters.
Players can even host their own Realms with custom servers and databases. These private Realms are independent of the official servers, so accounts created there won’t work on the main servers.
For custom Realms, players get all the tools they need to tweak game content—like adding new maps, items, monsters, and more. Plus, these custom servers will still show up in the game client’s server list for others to discover.
Why play it?
If you love retro-style indie games, Key To Heaven might be right up your alley. It has all the classic MMORPG staples: Randomized gear, crafting, raft, Questing, Raids...
But it also brings some fresh ideas to the table, like:
A built-in Battle Royale mode, where you can queue anytime for fast-paced, 2D combat with swords, bows, and spells. Ever tried that in a retro MMORPG?
Matchmaking for PvP, where you can safely face off against other players and climb the MMR leaderboard.
And there’s much more hidden beneath the surface, plenty to explore and discover as you play.
Website: https://key2heaven.com/
Download: https://store.steampowered.com/app/1347630/Key_To_Heaven/
Discord: https://discord.gg/TmHHJkG
r/visualbasic • u/khailuongdinh • Feb 24 '22
Tips & Tricks New book of Visual Basic .net -- get started, tutorials, reference
Hi all,
I have just found a document of Visual Basic .net recently posted a few days ago.
Overview of Visual Basic: https://docs.microsoft.com/en-us/dotnet/opbuildpdf/visual-basic/toc.pdf?branch=live (so-called as the book)
This book includes 1,332 pages. If you wish to focus on a topic (e.g. Language-Integrated Query - LINQ), you can click on the link in the book. It will refer us to the website which contains everything about this topic.
I think it will be very helpful for anyone who is interested in VB.NET, including beginners or even experienced programmers.
r/visualbasic • u/codeobserver • Oct 04 '26
I’m building a visual web app editor ... what Visual Basic could’ve been
Maybe it’s already too late for a tool like this. Nobody really does drag-and-drop anymore in the age of AI.
But if you want to take a look: appmaker.io
r/visualbasic • u/createaforum • Jul 30 '26
State of Decompiling of VB6 as July 2026
I have been focusing on decompiling native compiled programs for VB6 but also have P-Code as well.
Just showing what can be recovered in both compiled types:
https://vbsourcecoderecovery.com/state-of-vb6-decompiling-2026.html
Depending on the program you can get 75% to 85% of the way there and in some cases with AI improvements get the rest into a fully working program. I have done projects with 100k lines of code, with custom controls, API's etc.
Other tidbits: The current decompiler written in VB6. Can do .NET (VB,C#), VB5, VB3, QuickBasic 4.5. Probably can do versions but need more sample programs.
Currently works best with VB6 followed by .NET.
Background: Over 20 years ago I started worked on VB6 decompiler in college, my original goal was to recreate a VB6 game that I enjoying playing.
I had a period of it being open source, then closed source paid, then open again. And I have jumped back into it the last few months with the same goal I had when I first started.
r/visualbasic • u/FLMikw • Jun 19 '26
Development Tools Freeware
I recently released a freeware utility called SourceDoc Pro that I built for my own use and thought others in the VB6 community might find useful.
It reads a VB6 project file (.vbp), lets you select any combination of modules and procedures, and prints formatted documentation with syntax highlighting, visual loop bracket connectors, and procedure dependency reports showing call relationships across the entire project. Output goes to a printer or PDF file. A table of contents listing all project files and procedures can also be printed.
I am a retired engineer and hobbyist developer, not a professional programmer, so this is very much a "scratching my own itch" kind of project. I have been using it to document my own VB6 projects and found it genuinely useful for code review as well. It may be a useful tool for maintaining legacy VB6 programs, especially those created by someone else.
It is completely free, includes a full installer and User Manual, and runs on Windows 7 through 11.
You can download it from OlderGeeks at: https://www.oldergeeks.com/downloads/file.php?id=4974
Feedback welcome — happy to hear what works and what does not.
r/visualbasic • u/koss3982 • Apr 12 '21
RAD Basic: a 100% compatible Visual Basic 6 solution
Hi!
I'm Carles Royan and I've just begin a Kickstarter campaign for finishing the development of RAD Basic, a 100% compatible Visual Basic 6 solution. I've been developing it for two years, you could review demo videos on Kickstarter page, YouTube and website.
Let me sharing with you the kickstarter page:
https://www.kickstarter.com/projects/koss3982/rad-basic-a-100-compatible-visual-basic-6-solution
And website:
I think VB6 has room as a language nowadays and it could be evolved without loosing backward compatibility.
I hope you could help in crowdfunding campaign.
Thanks!!!
r/visualbasic • u/rogaatec • Aug 14 '19
VB6 Help Weird error after August 2019 patch day
After the patch day from yesterday our old vb6 application does not work properly anymore.
We got an error „invalid procedure call or call argument“. After debugging we identified the problem. We define a variable as an array of type Variant. When we now set the variable with an empty array, the application breaks.
The code looks like this:
Dim test() As Variant
test = Array() ' this line crashes the app
Does anyone know what the problem might be or which Update from Microsoft changed this behavior?
r/visualbasic • u/mika • 28d ago
VB6 MCP for agents
Hello again,
I've developed an MCP for VB6 which allows agent harnesses (mainly tested with Claude Code) if anybody is interested. You can find it at https://github.com/mika76/vb6-mcp
Basically it routes the agent to work through the IDE instead of directly onto the files. This enables some nice features like being able to work on non-saved files as VB6 does not automatically save files to disk, and it enabled debugging within the app. It also helps not to ask for UAC admin prompts all the time and knows how to work with COM components and their dependencies.
Anyway, if anybody is interested have a look.
r/visualbasic • u/Bonejob • Apr 30 '26
Mod Post What did you love about VB6, and what frustrates you about modern .NET?
Two open questions for anyone who shipped real work on Visual Basic 6.
I shipped roughly a hundred line-of-business systems on VB3 through VB6 between 1995 and 2010, then moved to C# and have been there ever since. I am writing a history of Visual Basic and the research keeps surfacing the same observation: WinForms in modern .NET is recognisably the same form-designer model VB6 invented, and twenty-eight years on it is still the shortest distance from "I have an idea" to "I have a running app." That is interesting, and I want to get under the usual "VB6 was a toy" or "VB6 was a masterpiece" framings to understand what was actually good.
Two questions, please answer either or both:
What specifically did you love about VB6? Not the general nostalgia. Specific things. A workflow, a design choice, something you reach for now and notice is missing.
What do you find frustrating about modern .NET, C#, and Visual Studio that VB6 didn't make you fight? Same shape. Specific examples. "I miss being able to do X without Y" rather than "it's too complicated."
Open-ended on purpose. If I gave you categories to choose from, the most interesting answers would be in the categories I didn't think of. Please reach for the specific example before the category.
Longer version of why I'm asking is on my blog if you want it: https://evilgeniuslabs.ca/blog/vb6-modern-dotnet-question. Replies here, though. The thread is the point.
Exploratory post. Not announcing anything today, not collecting emails. Just a writer trying to do a chapter justice while the people who lived this are still around to tell it. I will read every reply.
Thanks
Bone/EG
r/visualbasic • u/Bonejob • Nov 10 '25
Mod Post So what do we do with VB6 Sub reddit?
So, I am probably the last mod who is scanning /r/visualbasic
I don't practice much VB6 and VB.NET anymore, for all of my professional projects have migrated to C#, or Rust.
I don't think we should close the SUB, but there is really nothing going on with it. Most have moved on. What should we do with the Sub?
r/visualbasic • u/KaeruCT • Mar 18 '23
Article Something Pretty Right: A History of Visual Basic
r/visualbasic • u/krepzera • Feb 16 '20
This code compiles correctly in VisualStudio but not on hackerrank. On hackerrank it tells me that 'List' is not declared, but the code works in VS. Any suggestions?
r/visualbasic • u/Bonejob • May 21 '26
Article VB on Avalonia: the VB6 form-and-handler model, cross-compiled to Linux from Visual Studio 2026
r/visualbasic • u/ParisHL • Dec 12 '25
Can anyone recompile an old VB game for me that gives run-time error 6 Overflow issues?
I used to play this old Freeware game called Speedway Meeting that is compiled in Visual Basic 6. However, it won't run in Windows 11 as it says there's a "Runtime Error 6: Overflow". If I reduce my monitors resolution down to 1920x1080, it fixes the problem, but it isn't a long-term solution.
You can download the source code here: http://www.speedway-meeting.com/SpwyMtg511-Source.zip
Upon playing around with ChatGPT, it seems the error is somewhat easy to fix:
The problem (short)
Your project uses 16-bit Integer variables to hold screen/form coordinates and sizes (which are in twips in VB6). At high display resolutions those twip values exceed the Integer range (-32,768 .. 32,767) and VB throws an Overflow. Lowering resolution reduces the twip values below that limit, which is why the game runs at 1920×1080.
Exact places I found it
In Speedway.bas (module "General"):
Around line 2583 there are these declarations:
Dim MainWinX As Integer ' X position of Main Window
Dim MainWinY As Integer ' Y position of Main Window
Dim MainWinHeight As Integer ' Height of Main Window
Dim MainWinWidth As Integer ' Width of Main Window
Dim MainWinState As Integer ' Opening state of Main WindowLater (around lines 2695–2707) those variables are used with Screen.Width / Screen.Height and assigned to frmMainWin.Width, frmMainWin.Height, frmMainWin.Left, etc:
Select Case MainWinWidth
Case 1680 To Screen.Width
frmMainWin.Width = MainWinWidth
Case Else
If Screen.Width < 7000 Then
frmMainWin.Width = Screen.Width
Else
frmMainWin.Width = 7000
End If
End SelectScreen.Width and Screen.Height return values in twips. On large displays (e.g. 3840×2160) twips easily exceed 32767.
Also the module has DefInt A-Z at the top (Speedway.bas contains DefInt A-Z), which makes many undeclared variables default to 16-bit Integer. That makes the overflow risk widespread.
How to fix (recommended)
Use 32-bit Long for any variables that hold pixel/twip sizes, coordinates or anything derived from Screen.Width, Screen.Height, form .Width/.Height/.Left/.Top, API calls returning sizes, etc.
Replace those specific declarations in
Speedway.bas:
' change this:
Dim MainWinX As Integer
Dim MainWinY As Integer
Dim MainWinHeight As Integer
Dim MainWinWidth As Integer
Dim MainWinState As Integer
' to this:
Dim MainWinX As Long
Dim MainWinY As Long
Dim MainWinHeight As Long
Dim MainWinWidth As Long
Dim MainWinState As Long2. Remove or change the DefInt A-Z at the top of Speedway.bas. Two options:
Remove
DefInt A-Zentirely and explicitly declare variables withAs Longwhere appropriate (preferred for clarity).Or change it to
DefLng A-Z(less preferred because it hides types and can mask other problems, but it will prevent 16-bitIntegeroverflow).
Search the project for other variables used with
Screen.*, form dimensions, or API calls and ensure they areLong. Typical suspects: anyLeft, Top, Width, Height, X, Yvariables, window position/state variables, API declared parameters expectingLong.Check any
Val(...)or registry reads that write to those variables — ensure the receiving variable type isLong(you alreadyVal()strings that may be >32K).
Why this works
VB6 properties like .Left, .Width, .Height and Screen.Width return/expect twips (and many Windows API functions use 32-bit values). Using Long (32-bit signed) allows values up to about 2 billion and avoids overflow on modern displays.
Quick checklist to run after changes
Change the
Dimlines as above.Remove or replace
DefInt A-Z.Grep the project for
As Integerwhere the variable name implies a size/coordinate and evaluate whether it needs to beLong.Recompile and test at your native high resolution (e.g. 3840×2160). The overflow should be gone.
Would anyone be able to help me by fixing this error to make it compatible in Windows 11 and bigger resolutions? I'm happy to make a small donation to a charity of your choosing for helping (I'm based in Australia, so an international charity would probably make the most sense).
Thanks for any help you can provide.
r/visualbasic • u/revennest • Mar 09 '21
Article How to quickly learn VB.Net before exam - 1
I saw many student here and I hardly saw anyone fully understand basic of programing with VB.net so I create this post for any student to quickly train before final exam, let's start.
Start with Console application

After create the first thing you will see is this code.
Module Module1
Sub Main()
End Sub
End ModuleWe have 2 things here
Moduleis a class type, you can think it as a holder of value and method.Subis method type return nothing.
For summary method is when you do something like eating, running, etc and class is like a class room for store thing and do activity inside it.
Interaction with console
It's only has 2 thing for you to do with it
Receive text : when this happen you code will pause and wait until you complete input process.
Console.Read for receive a character.
Console.ReadKey for receive a key you press on keyboard.
Console.ReadLine for receive a line text, you will use this a lot, you need to press key enter to finish a line.
Show text : show a text you create to screen.
Console.Write for write a text.
Console.WriteLine for write a text and enter a new line.
First thing you need to write to your current code
It is Console.ReadKey because it make your app wait for you to press any key, without it you app will shutdown immediately after run all code because it finish do all thing, so you code will look like this.
Module Module1
Sub Main()
Console.ReadKey()
End Sub
End ModuleWhy and () after Main and Console.ReadKey ?
(...) for receive data into method, let's do it with Console.WriteLine.
Module Module1
Sub Main()
Console.WriteLine("Hi friend")
Console.ReadKey()
End Sub
End ModuleHi friend.
You need to quote(") for let VB know it's text.
Can you Sub Main("Hello") ?
Answer is No, Sub and Function is declaring aka create method not using it so you can't just push data in to it.
Declaring variant
Data like water, it can't stay it own without anything contain it for long so you need a variant for it via Dim keyword.
Module Module1
Sub Main()
Dim Index = 100
Console.WriteLine(Index)
Console.ReadKey()
End Sub
End Module100
If you lean from school you maybe notice I don't define type for variant like Dim Index As Integer = 100 because you doesn't need care about it yet, you still too beginner for this topic.
Repeating code
For example, you want to show number 1 to 5 on screen you might be code like this.
Module Module1
Sub Main()
Console.WriteLine(1)
Console.WriteLine(2)
Console.WriteLine(3)
Console.WriteLine(4)
Console.WriteLine(5)
Console.ReadKey()
End Sub
End ModuleAnd if you teacher change it be 1 to 20, you also might be code like this to avoid typing number to all write line.
Module Module1
Sub Main()
Dim N = 1
Console.WriteLine(N)
N = N + 1
Console.WriteLine(N)
N = N + 1
Console.WriteLine(N)
N = N + 1
Console.WriteLine(N)
N = N + 1
Console.WriteLine(N)
N = N + 1
Console.WriteLine(N)
N = N + 1
Console.WriteLine(N)
N = N + 1
Console.WriteLine(N)
N = N + 1
Console.WriteLine(N)
N = N + 1
Console.WriteLine(N)
N = N + 1
Console.WriteLine(N)
N = N + 1
Console.WriteLine(N)
N = N + 1
Console.WriteLine(N)
N = N + 1
Console.WriteLine(N)
N = N + 1
Console.WriteLine(N)
N = N + 1
Console.WriteLine(N)
N = N + 1
Console.WriteLine(N)
N = N + 1
Console.WriteLine(N)
N = N + 1
Console.WriteLine(N)
N = N + 1
Console.WriteLine(N)
Console.ReadKey()
End Sub
End ModuleBut when your teacher change it to be 1 to 10,000 , are you still use those 2 above ? I believe no one want to do it like that so what should you do then ?
Do
LoopWe use Do Loop for this type of work and when you see block code like this it call a scope which mean their job limit within this block, before and after block is nothing to do with it.
However you can't just use it like that, if you use it like that you will get infinity loop like Dr. Strange "I've come to bargain" so you need to create exit for it.
Dim N = 1
Do Until N > 10000
N = N + 1
LoopOr you can use while instead like this.
Dim N = 1
Do While N <= 10000
N = N + 1
LoopIf it's surely not going to finish on first loop, you can move exit check after loop instead after do like this
Dim N = 1
Do
N = N + 1
Loop Until N > 10000In do while.
Dim N = 1
Do
N = N + 1
Loop While N <= 10000Well, let do 1 to 10,000 then.
Module Module1
Sub Main()
Dim N = 1
Do Until N > 10000
Console.WriteLine(N)
N = N + 1
Loop
Console.ReadKey()
End Sub
End ModuleIt's much more simple, isn't it.
Why don't I use For Next instead Do Loop ?
Do Loop is the most simple way to repeat code and no hidden code secretly create for it so you should start with cleanest code for avoid unknow error cause by hidden code.
Boolean, the result of comparing
Boolean has only 2 value, it's True and False , you should familiar with it in math subject, > < = And Or Xor Not , you already use it above on create exit on Do Loop so it's nothing new or hard like in your math subject, don't worry about it.
Where you need to use this Boolean ?
When you need to create intersection, like in do loop code, without exit intersection you going to stuck in infinite loop.
Intersection aka Branching code
When your code need to response with uncertain situation that you're not sure what's store in variant then you need intersection for it.
If Score < 50 Then Console.WriteLine("You're fail.")
If Score => 50 Then
Console.WriteLine("You're pass.")
End If
If Score < 50 Then
Console.WriteLine("You're fail.")
Else
Console.WriteLine("You're pass.")
End If
If Score < 50 Then
Console.WriteLine("You're fail.")
ElseIf Score => 80
Console.WriteLine("You're legendary.")
Else
Console.WriteLine("You're pass.")
End IfIt isn't hard to understand, right ? only Else might be some confuse but it mean if non result of compare within scope is true then do this.
However if you code look like this.
If Kill_count = 5 Then
Console.WriteLine("Pentra Kill")
ElseIf Kill_count = 4 Then
Console.WriteLine("Quater Kill")
ElseIf Kill_count = 3 Then
Console.WriteLine("Triple Kill")
ElseIf Kill_count = 2 Then
Console.WriteLine("Double Kill")
End IfYou could change it to a new intersection type, call Select Case.
Select Case Kill_count
Case 5
Console.WriteLine("Pentra Kill")
Case 4
Console.WriteLine("Quater Kill")
Case 3
Console.WriteLine("Triple Kill")
Case 2
Console.WriteLine("Double Kill")
End SelectSelect Case is much easy then if but you need you beware about what's you use to be select case when you use Is like this.
Select Case Score
Case Is > 79
Console.WriteLine("Gold medal")
Case Is > 69
Console.WriteLine("Silver medal")
Case Is > 59
Console.WriteLine("Bronze medal")
Case Else
Console.WriteLine("Stone medal")
End SelectArray aka Group of something
First thing when you indexing it, It's not start from 1 but start at 0 so the first member of it is 0 not 1 don't forget it, it will confuse you with its length if you forget.
Dim Scores = {70, 50, 65, 80, 40}
Console.WriteLine(Scores(0))
Console.WriteLine(Scores(3))
Console.WriteLine(Scores(5))
Console.WriteLine(Scores.Length)70
65
40
5
Example how are you going to use it and use it a lot.
Dim Names = {"Tom", "Dirk", "Henry", "Jon", "Jame"}
Dim Scores = {70, 50, 65, 80, 40}
Dim Max = If(Names.Length > Scores.Length, Scores.Length, Names.Length)
Dim Index = 0
Do While Index < Max
Dim Name = Names(Index)
Dim Score = Scores(Index)
Select Case Score
Case Is > 79
Console.WriteLine(Name & " got gold medal")
Case Is > 69
Console.WriteLine(Name & " got silver medal")
Case Is > 59
Console.WriteLine(Name & " got bronze medal")
Case Else
Console.WriteLine(Name & " got stone medal")
End Select
Index = Index + 1
LoopAlright, it should cover most basic of coding within method scope, if you get all of this, I believe you should not got much trouble to manipulate flow of data to fit you logic code and get result you need.
See you next in post.
r/visualbasic • u/[deleted] • Jan 06 '21