Jump to content

Visual Basic: "Yay", "Nay" or "Blech!!!"?

pipnina

I've had to use Visual Basic for my college project (whack a zergling). It seems all right to me so far but is possibly a bit slow, but then I'm almost definitely using it wrong. What's the general consensus on the language/IDE from people in the know? Personally, I found it to be quite frustrating as the IDE has a lot of different versions and they aren't all cross-compatible... and the ISO file from Dreamspark won't install on my PC (Tried multiple disks, still nothin'). And when I tried to use it to write in C++ it spat out errors in the most non-sensible way possible (Like 20 pages of gibberish instead of 2/3 red lines of something that makes sense in Code::Blocks.)

 

    ~pip

Link to comment
Share on other sites

Link to post
Share on other sites

goo c++ or go home

visual basic is like drinking bleach - it makes your brain sad

 

Since you have Dreamspark get Visual Studio, what the hell were you using before?

if nothing works then just write it in notepad and compile online, kek

CPU: Intel i7 5820K @ 4.20 GHz | MotherboardMSI X99S SLI PLUS | RAM: Corsair LPX 16GB DDR4 @ 2666MHz | GPU: Sapphire R9 Fury (x2 CrossFire)
Storage: Samsung 950Pro 512GB // OCZ Vector150 240GB // Seagate 1TB | PSU: Seasonic 1050 Snow Silent | Case: NZXT H440 | Cooling: Nepton 240M
FireStrike // Extreme // Ultra // 8K // 16K

 

Link to comment
Share on other sites

Link to post
Share on other sites

Blech.......

Kinda outdated

C++ C# Python Javascript are my favorites.

Any PSU is modular if you try hard enough....

Link to comment
Share on other sites

Link to post
Share on other sites

VB? Had to use it for a thesis project in my first year undergrad... haven't found the need to use it since. And that was nearly 20 years ago.

 

Though I do know some people who use code based on VB, for creating macros in Microsoft Office.  Especially with Access.

Guide: DSLR or Video camera?, Guide: Film/Photo makers' useful resources, Guide: Lenses, a quick primer

Nikon D4, Nikon D800E, Fuji X-E2, Canon G16, Gopro Hero 3+, iPhone 5s. Hasselblad 500C/M, Sony PXW-FS7

ICT Consultant, Photographer, Video producer, Scuba diver and underwater explorer, Nature & humanitarian documentary producer

Link to comment
Share on other sites

Link to post
Share on other sites

I still don't understand why people use VB.NET nowadays.

Link to comment
Share on other sites

Link to post
Share on other sites

4 minutes ago, DXMember said:

goo c++ or go home

visual basic is like drinking bleach - it makes your brain sad

 

Since you have Dreamspark get Visual Studio, what the hell were you using before?

if nothing works then just write it in notepad and compile online, kek

 

2 minutes ago, xiej said:

Blech.......

Kinda outdated

C++ C# Python Javascript are my favorites.

 

Just now, ALwin said:

VB? Had to use it for a thesis project in my first year undergrad... haven't found the need to use it since. And that was nearly 20 years ago.

This sounds like a resounding "Blech!". Slightly surprised. I had assumed my program running like a snail to be my fault...

Link to comment
Share on other sites

Link to post
Share on other sites

Don't discount VB as a useless language.  It can be used to do a lot of things as almost any other programming languages and is much simpler than most.  But that simplicity can be one of its greatest weaknesses.

 

I wrote a Chess program using VB for my undergrad course.

 

FYI, I stopped being a SE nearly a decade ago so my knowledge about programming languages may sometimes be outdated.

Guide: DSLR or Video camera?, Guide: Film/Photo makers' useful resources, Guide: Lenses, a quick primer

Nikon D4, Nikon D800E, Fuji X-E2, Canon G16, Gopro Hero 3+, iPhone 5s. Hasselblad 500C/M, Sony PXW-FS7

ICT Consultant, Photographer, Video producer, Scuba diver and underwater explorer, Nature & humanitarian documentary producer

Link to comment
Share on other sites

Link to post
Share on other sites

I have to work with Visual Basic .NET on a daily basis and it isn't that bad of a language to work with. The syntax is a bit too verbose for my liking but you get used to it (I'm sure some people out there even like it). I can understand why some beginner classes pick it for their language. I consider C# to be a better option these days for .NET development though. Without getting into language differences, C# is simply more popular and more of a priority for Microsoft and other developers. Many tools/platforms support C# exclusively (or at least better than VB).

 

When it comes to performance, for many applications the performance of VB should be just fine. You wouldn't want to use VB for performance critical tasks, but then you probably wouldn't be using C#, Python, Java, or a number of languages for it either. When you need performance you generally go with C, C++, or something like that. It's certainly possible that improving your code would increase performance but you may also be able to improve performance through the compiler settings. Compiling in release mode with optimizations enabled might help if you've only been using debug mode. You could also try native compilation.

 

The Visual Studio IDE is generally considered to be a really good IDE for Windows. I don't know what version you're using but usually it's best to stick with the current version unless you have a reason not to (like you're working on a project from an older version that you can't upgrade). If you have to work with multiple versions, then you can install multiple versions side by side. I have both VS 2012 and VS 2015 on my computer at the moment and used to have some older versions installed too. It's certainly not ideal but it's never caused me any issues either.

 

I can't speak to what it's like to develop in C++ with Visual Studio and Microsoft's compiler. Whenever I use C++ I use a text editor or the CLion IDE with g++ as my compiler.

Link to comment
Share on other sites

Link to post
Share on other sites

A bit slow:

I'm going to guess (i) you're talking about VB.Net not an older version (ii) your project was some form of game and (iii) you're not using any extra libraries such as DirectX etc.? Knowing this or looking at some of your source code could help us better comment on the speed improvements (also the general tips which madknight3 has mentioned will be useful).

 

What's the general consensus on the language/IDE from people in the know?

It's got a bad rep from (i) the pre-.net version days and from people who've read anything from this era on the net and spread the comments without ever bothering to try programming in it. I've used it most of my programming career & there's still many jobs out there & all sized companies which ask for it. If you're starting out in .net programming however, C# is the preferred language which will open more doors for you & get you learning case sensitivity and that matching opening & closing brackets matter ... a lot... which would prepare you to switch to more, other languages more easily later in life if you want/need to.

 

IDE versions

Yep the VS IDE (I'm guessing you're talking about) & the .net framework have caused a few headaches.

Generally I'd say the IDE itself hasn't changed too much apart from styling or new bits being bolted on. The shortcut keys, menu placements etc. for me at least I've not noticed wildly different between versions. If you're talking about the lightbox/lightswitch whatever that was or visual studio code then those are very different beasts though designed not to be backward compatible with the usual VS.

 

ISO file install

What error(s) are you getting? Also, I don't know how dreamspark works, but do you get a license key - i.e. is it possible to download the IDE from antoher area such as msdn?

 

C++

Were you upgrading a project? Again it's difficult to comment here without knowing what errors, what settings or add-ons you might have (anything like the older fxcop etc.) and what your code/project look like...

Link to comment
Share on other sites

Link to post
Share on other sites

15 hours ago, pipnina said:

I've had to use Visual Basic for my college project (whack a zergling). It seems all right to me so far but is possibly a bit slow, but then I'm almost definitely using it wrong. What's the general consensus on the language/IDE from people in the know? Personally, I found it to be quite frustrating as the IDE has a lot of different versions and they aren't all cross-compatible... and the ISO file from Dreamspark won't install on my PC (Tried multiple disks, still nothin'). And when I tried to use it to write in C++ it spat out errors in the most non-sensible way possible (Like 20 pages of gibberish instead of 2/3 red lines of something that makes sense in Code::Blocks.)

 

    ~pip

try and learn Visual C# .NET . It's not that hard. All you need is Visual Studio 2015 Community and it's free.

Judge a product on its own merits AND the company that made it.

How to setup MSI Afterburner OSD | How to make your AMD Radeon GPU more efficient with Radeon Chill | (Probably) Why LMG Merch shipping to the EU is expensive

Oneplus 6 (Early 2023 to present) | HP Envy 15" x360 R7 5700U (Mid 2021 to present) | Steam Deck (Late 2022 to present)

 

Mid 2023 AlTech Desktop Refresh - AMD R7 5800X (Mid 2023), XFX Radeon RX 6700XT MBA (Mid 2021), MSI X370 Gaming Pro Carbon (Early 2018), 32GB DDR4-3200 (16GB x2) (Mid 2022

Noctua NH-D15 (Early 2021), Corsair MP510 1.92TB NVMe SSD (Mid 2020), beQuiet Pure Wings 2 140mm x2 & 120mm x1 (Mid 2023),

Link to comment
Share on other sites

Link to post
Share on other sites

16 hours ago, pipnina said:

 

 

This sounds like a resounding "Blech!". Slightly surprised. I had assumed my program running like a snail to be my fault...

Your program shouldn't be slow regardless unless you are doing highly complicated and mission critical scientific calculations

what exactly is your program doing?

CPU: Intel i7 5820K @ 4.20 GHz | MotherboardMSI X99S SLI PLUS | RAM: Corsair LPX 16GB DDR4 @ 2666MHz | GPU: Sapphire R9 Fury (x2 CrossFire)
Storage: Samsung 950Pro 512GB // OCZ Vector150 240GB // Seagate 1TB | PSU: Seasonic 1050 Snow Silent | Case: NZXT H440 | Cooling: Nepton 240M
FireStrike // Extreme // Ultra // 8K // 16K

 

Link to comment
Share on other sites

Link to post
Share on other sites

9 hours ago, alex_read said:

A bit slow:

I'm going to guess (i) you're talking about VB.Net not an older version (ii) your project was some form of game and (iii) you're not using any extra libraries such as DirectX etc.? Knowing this or looking at some of your source code could help us better comment on the speed improvements (also the general tips which madknight3 has mentioned will be useful).

 

What's the general consensus on the language/IDE from people in the know?

It's got a bad rep from (i) the pre-.net version days and from people who've read anything from this era on the net and spread the comments without ever bothering to try programming in it. I've used it most of my programming career & there's still many jobs out there & all sized companies which ask for it. If you're starting out in .net programming however, C# is the preferred language which will open more doors for you & get you learning case sensitivity and that matching opening & closing brackets matter ... a lot... which would prepare you to switch to more, other languages more easily later in life if you want/need to.

 

IDE versions

Yep the VS IDE (I'm guessing you're talking about) & the .net framework have caused a few headaches.

Generally I'd say the IDE itself hasn't changed too much apart from styling or new bits being bolted on. The shortcut keys, menu placements etc. for me at least I've not noticed wildly different between versions. If you're talking about the lightbox/lightswitch whatever that was or visual studio code then those are very different beasts though designed not to be backward compatible with the usual VS.

 

ISO file install

What error(s) are you getting? Also, I don't know how dreamspark works, but do you get a license key - i.e. is it possible to download the IDE from antoher area such as msdn?

 

C++

Were you upgrading a project? Again it's difficult to comment here without knowing what errors, what settings or add-ons you might have (anything like the older fxcop etc.) and what your code/project look like...

I wasn't using anything but the default template when you open VS in general development. 

Can't remember what errors I was getting in the install. But there was no license key.

 

With the C++ I took the default "New project", added an cout << "Hello" << endl; and it didn't like it. The error was very long. I don't think I even told it to import any libraries, either. it was only to get it to print out Fibonacci numbers and I just used python in the end. I normally use Code::Blocks for C++ anyway. (It was free9_9)

2 hours ago, DXMember said:

Your program shouldn't be slow regardless unless you are doing highly complicated and mission critical scientific calculations

what exactly is your program doing?

If google lets you download it... THIS is my project in its rather incomplete form. I notice that things flicker a lot when changing between the game and the main menu etc.

Mind, this is probably because I just drag objects in and make things invisible...

Link to comment
Share on other sites

Link to post
Share on other sites

So it was a game then. Basically you'll want to read up on (i) why winforms are a bad idea generally for game drawing (ii) using some form of game engine or sdk highly optimised for thee such tasks and (iii) buffering or frame buffering to get that running smoother & faster.

 

I've just found this which'll give you some further tips:  http://social.technet.microsoft.com/wiki/contents/articles/17358.how-to-create-video-games-in-vb-net-windows-forms.aspx

Link to comment
Share on other sites

Link to post
Share on other sites

2 hours ago, pipnina said:

If google lets you download it... THIS is my project in its rather incomplete form. I notice that things flicker a lot when changing between the game and the main menu etc.

Mind, this is probably because I just drag objects in and make things invisible...

Part of your problem is that you're using WinForms which is very inefficient at rendering controls. WPF is a better UI framework and is much more efficient so if you ever have the chance to use it over WinForms then I would take it.

 

Anyway, I'll continue on with suggestions for WinForms in case you can't switch. One option for improving performance is to limit how many times the form/controls need to render for a given action. You can visually see how many rendering calls are made by adding in the following methods to Form1, setting breakpoints in them, and going through the programs execution in debug mode.

Protected Overrides Sub OnPaint(e As PaintEventArgs)
    MyBase.OnPaint(e)
End Sub

Protected Overrides Sub OnPaintBackground(e As PaintEventArgs)
    MyBase.OnPaintBackground(e)
End Sub

Every time something changes, like the visibility of a control, either OnPaint or OnPaintBackground (or both) will fire. This is why you see the flickering when you're in a game and click the menu button. All those control changes make a lot of paint calls.

 

One way to reduce that is to group items inside a panel. For example you could have all the game items reside in a single panel. Then you switch the visibility of the panel(s) on and off and reset the state of the other controls when the panel is hidden. This way, there doesn't need to be any calls to the paint events for each control inside the panel.

 

Example

Function menu_state() As Single
    ' First set the panel visibility to False
    GamePanel.Visible = False

    ' Now since nothing is displayed on screen, set everything else

    'Makes the instructions invisible
    Instructions.Visible = False

    'Makes the display text and value for score invisible
    Label_Score_Number.Visible = False
    Label_Score_Text.Visible = False

    ' etc
End Function

Function game_state() As Single
    ' Set everything before displaying panel

    'Makes the instructions invisible
    Instructions.Visible = False

    'Makes the display text and value for score visible
    Label_Score_Number.Visible = True
    Label_Score_Text.Visible = True

    ' etc

    ' Now set the panel at the end of the function
    GamePanel.Visible = True
End Function

You should notice a performance improvement and much less flickering with this simple change.

 

Another thing to comment about is that as the application grows, the form designer gets very cluttered and hard to work with. Your application form is already pretty cluttered with your game controls over your menu controls and what not. So you should also split the UI up across multiple files like with other forms or custom user controls.

Link to comment
Share on other sites

Link to post
Share on other sites

3 hours ago, pipnina said:

If google lets you download it... THIS is my project in its rather incomplete form. I notice that things flicker a lot when changing between the game and the main menu etc.

Mind, this is probably because I just drag objects in and make things invisible...

To go along with my above post, here's a couple other things I wanted to mention about your code.

 

If you're using Function, it should return a value. If you don't need the method to return a value (think of a void function from other languages) you should be using Sub instead.

Public Function MyFunc() As Single
    ' Do some stuff

    Return 1.5 ' or whatever
End Function

Public Sub MySub()
    ' Do some stuff

    ' Doesn't return a value
End Sub

When it comes to logic, you should be aware of the difference between And/AndAlso and Or/OrElse. Usually you'll want to use AndAlso over And, and OrElse over Or. AndAlso and OrElse will only continue evaluation of the other conditions if it needs to. This is known as short circuit evaluation. Example

If Instructions.Visible = False And instructionsAvailable = True Then
    ' ...
End If

' The above code will check if Instructions.Visible is false and then check if instructionsAvailable is True.
' However because And will only run the code if both conditions are True, we only need to check the second condition
' if the first condition is True. If the first condition is False, then the result of the expression will be false no
' matter what the second condition is.

If Instructions.Visible = False AndAlso instructionsAvailable = True Then
    ' ...
End If

' Now the above code will only check the second condition if the first condition is True.
' In this specific example it doesn't seem important, but in many cases you'll be doing something like

If something IsNot Nothing AndAlso something.Func() = "whatever" Then
    ' Do something
End If

' In this case, if you used And instead of AndAlso, the second condition would throw an exception.
' OrElse is the opposite. If one of the conditions are true, then it can stop checking the other conditions.

Also, when you're using the Boolean type, you don't need to explicitly state equality. Example

If Instructions.Visible = True Then

' the above can be simplified to

If Instructions.Visible Then


' and the following 

If Instructions.Visible = False Then

' can be simplified to

If Not Instructions.Visible Then

I would also recommend turning Option Strict On for any VB projects you work on. This setting can be found in the compile tab of your projects properties. With Option Strict Off, VB will do a lot of things for you at compile time (like type conversion). As a beginner, I think it's more valuable to know how to do these things yourself as. Once you get more experienced, it's your choice to have it on or off. Personally I still like to have Option Strict On to get more help from the compiler. In your code, turning Option Strict On will make you change a few small things. You may also want to treat all warnings as errors as well for the same reason. This setting is also found in the compile tab of your projects properties.

 

Finally, the last thing I wanted to mention is your use of Console.WriteLine in the GUI app. If you're only using it to help you debug your program, consider using Debug.Print instead. Debug.Print statements only execute when running the application in Debug mode. This way, when you run your code in Release mode, you don't have the extra Console.WriteLine calls being executed when no one is going to see them anyway.

 

That should be plenty of information to process for now. If you have any questions about what I've written, you can send me a message or post here and I can help further.

Link to comment
Share on other sites

Link to post
Share on other sites

5 hours ago, pipnina said:

If google lets you download it... THIS is my project in its rather incomplete form. I notice that things flicker a lot when changing between the game and the main menu etc.

Mind, this is probably because I just drag objects in and make things invisible...

ok... Basic wasn't really designed for making games you know...

chose the right tool for the right job man...

CPU: Intel i7 5820K @ 4.20 GHz | MotherboardMSI X99S SLI PLUS | RAM: Corsair LPX 16GB DDR4 @ 2666MHz | GPU: Sapphire R9 Fury (x2 CrossFire)
Storage: Samsung 950Pro 512GB // OCZ Vector150 240GB // Seagate 1TB | PSU: Seasonic 1050 Snow Silent | Case: NZXT H440 | Cooling: Nepton 240M
FireStrike // Extreme // Ultra // 8K // 16K

 

Link to comment
Share on other sites

Link to post
Share on other sites

On 04/02/2016 at 11:22 PM, madknight3 said:

I can't speak to what it's like to develop in C++ with Visual Studio and Microsoft's compiler. Whenever I use C++ I use a text editor or the CLion IDE with g++ as my compiler.

It's fantastic, they have come a long way with it, check out it's feature set. Combined with the latest ReSharper it is awesome. Only bad point is that of course it's platform specific. However as you said we now have CLion which is built on the ReSharper technology... When an organization is open to buying it that is, else it's Eclipse CDT.

 

I'd have more to say about all of this thread in general but I've got flu atm :( so I've no energy for it right now really...

The single biggest problem in communication is the illusion that it has taken place.

Link to comment
Share on other sites

Link to post
Share on other sites

Thanks for all the help guys! I'll bear your recommendations in mind, @madknight3.

 

I wasn't really choosing VB.net for the game because it would be the ideal solution, @DXMember ... But because it would be the easiest for me to use. I could have made it in JavaScript or downloaded Unity and made it in that but that would have taken more time.

Although, considering the problems I've had with installing VB on my PC and how nice Unity is with licensing, it may have been the better option in the end to go with unity but at the time it wasn't installed in my college room which made it an unattractive choice. That and I was struggling to get to grips with JavaScript (Tried, failed, went to something else lol)

 

@Nuluvius How recently has it improved? I was using Visual Studio 2010 and I think there's been 2013 and 2015 since. Also hope you get over your flu!

 

 

    ~pip

Link to comment
Share on other sites

Link to post
Share on other sites

7 hours ago, pipnina said:

@Nuluvius How recently has it improved? I was using Visual Studio 2010 and I think there's been 2013 and 2015 since.

I'd say since the advent of 2013, though there were still some features from the newer C++ specifications missing such as constexpr. As you can see from the chart that I linked they have been rapidly bridging those gaps.

 

Furthermore VIsual Studio post 2012 in it's quintessential, unaugmented form (minus ReSharper) has rather good C++ intellisense. As I recall 2010 had rather dire native (and V) C++ support as Microsoft was less interested in it at the time.

 

These improvements are (obviously) directly proportional to Microsoft's endeavours with the Universal WIndows Platform (UWP).

 

7 hours ago, pipnina said:

Also hope you get over your flu!

Thank you. My kids had it first and evidently it's now my turn :D

The single biggest problem in communication is the illusion that it has taken place.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×