![]() |
Statusbar + Basics [HUGE] - Printable Version +- Sinisterly (https://sinister.ly) +-- Forum: Coding (https://sinister.ly/Forum-Coding) +--- Forum: Visual Basic & .NET Framework (https://sinister.ly/Forum-Visual-Basic-NET-Framework) +--- Thread: Statusbar + Basics [HUGE] (/Thread-Statusbar-Basics-HUGE) |
Statusbar + Basics [HUGE] - Electroalek - 07-05-2013 NOTE:This tutorial is very detailed and it includes a lot of information for many basic things. If you don't really want to read them, just skip them ![]() Ever wanted to make a status bar under your progressbar that shows some progress of your application? Well of you don't know how, here is an opportunity to learn. I've seen a lot of different ways of doing it, but I personally think that this is the easiest method of doing this simple job. We are going to use a short declaration of an array and simple looping to display the message in the status bar(label). First let's learn how to declare an array with multiple strings in one line(for those that don't know how). Because I know that a lot of newbies will do this to declare an array: Code: Dim x(3) As String But this is the method that you wanna use: Code: Dim x() As String = {"Test", "LOL", "Hey", "etc..."} Now, lets learn how to call the elements of the array one after another. We can use a For Loop, we can use timer or we can use the value of a progressbar, trackbar and many different INTEGER values. Using a For Loop: Code: Code: Dim x() As String = {"Test", "LOL", "Hey", "etc..."} 'First we declare the array with the method that I explained above Code: 'This code is in a timer, with a variable that you want(doesn't matter) Using another value: Code: 'Imagine that y is the value that is the value that is set by completely other process. Keep in mind that this is most likely going to result in an error, because the source of the "outside" value is unpredictable, it might fail and this snippet will fail. But if you still want to use this then just add the code in a Try-Catch statement. Try-Catch statement is something like an if statement that checks if there is an error, if there is then do something below Catch. But if we leave it blank, it won't do anything, so we can use it for making error free applications(for those who don't know). Here is an example of usage of this code for the snippet above: Code: 'Read the above snippet for an explanation of this code And finally let's learn something about the Select statement. This statement are used instead of multiple if statements. If you for example need to do some action for each letter in the alphabet, you need to check if the variable is the desired letter with an if statement, that is a lot right. But with this statement you can set one variable to be checked, and then you can add multiple cases to be checked. Here is an example: Code: Dim x As String = "a" Code: Dim count As Integer 'We declare a blank integer first outside the timer [color=#1E90FF][size=x-large]Sorry for any errors or mistakes, if there are any ![]() I hope you liked this tutorial. By: Electroalek RE: Statusbar + Basics [HUGE] - Platinum - 07-30-2013 (07-30-2013, 06:51 AM)Dr Satan Wrote: Nice tut for beginners. Good way to teach arrays! It's not about the arrays though. Good tutorial but a bit hard to read, change the color maybe? RE: Statusbar + Basics [HUGE] - Blue - 07-30-2013 Stop trying to advertise your blog I removed your link. |