20
2011
Do Loops in VB .NET
Number of View: 0We saw with the For Loop that a specific number of times to loop was coded into it. We said For startNumber = 1 To 4 We knew that we only wanted to loop four times. But what if we don’t know how many times around the loop we want to go? Later, we’ll be opening text files and reading the data from them. If we used a For loop to get [...]
20
2011
For Loops in VB .NET
Number of View: 0This first type of loop we’ll look at is called a For Loop. It is the most common type of loop you’ll use when you programme. We’ll use one to add up our 4 numbers, and then discuss the code. Study the following. In fact, create a new Project. Add a button to your new Form. Double click your new button and type the following code for it: Dim answer As Integer [...]
20
2011
An Introduction to Loops
Number of View: 0There are three types of loop for us to cover with VB.NET: a For loop, a Do loop, and a While … End While loop. This last one is almost the same as a Do loop, and we won’t be covering it here. But the other two types of loop come in very handy, and a lot of the time you can’t programme effectively without using loops. What is a Loop? [...]
20
2011
Section Three Exercises
Number of View: 288Part 1 – If statements Start a new project. Add a textbox, a Label and a button to your new Form. Then write a programme that does the following: Asks users to enter a number between 10 and 20. The number will be entered into the Textbox. When the Button is clicked, your Visual Basic code will check the number entered in the Textbox. If it is between 10 and 20, then [...]
20
2011
Conditional Operators
Number of View: 482 The Conditional Operators allow you to refine what you are testing for. Instead of saying “If X is equal to Y”, you can specify whether it’s greater than, less than, and a whole lot more. Examine the list of Operators: Operator Meaning > This symbol means Is Greater Than and is used like this: If number > 10 Then MsgBox “The Number was Greater Than 10″ End If < This [...]
20
2011
Add a Combo Box to a VB .NET form
Number of View: 0Create a new project for this section. Add a button to your new form. Then, locate the Combo Box on the Visual Basic .NET toolbar. It looks like this: Double click the icon to add a Combo Box to your form. Or click once with the left hand mouse button, and then draw one on the form. A combo box is a way to limit the choices your user will have. When [...]
20
2011
Conditional Logic – If Statements
Number of View: 0What is conditional logic? Well, it’s something you use in your daily life all the time, without realising you’re doing it. Suppose that there is a really delicious cream cake in front of you, just begging to be eaten. But you are on a diet. The cake is clearly asking for it. So what do you do, eat the cake and ruin your diet? Or stick to your diet and let somebody [...]
20
2011
Select Case Statements
Number of View: 0The Select Case statement is another way to test what is inside of a variable. You can use it when you know there is only a limited number of things that could be in the variable. For example, suppose we add another choice for that cream cake. We’ve only said that the consequences of eating the cream cake is that the Diet will be either “Ruined” or “Not Ruined”. But what if [...]
20
2011
Coding the Plus Button
Number of View: 0Let’s remind ourselves how our calculator from the previous section works works. To add up 5 + 9, we’d do this: Click first on the 5 A 5 appear in the textbox Click the + symbol The 5 disappears from the textbox Click on the number 9 A 9 appears in the textbox Click on the = symbol The 9 disappears from the textbox The answer to 5 + 9 appears in [...]
An article by Dr. Zia-al-Hassan