Monday, January 31, 2011

Programming 2 /* If Statements */

An "If" statement in Visual Basic is a comparison statement that evaluates to true or false. If the statement evaluates to true, then the inner statements within the "If" block are executed. If the statement evaluates to false, then the compiler skips over the comparison statement and executes the following lines of code. "If" statements are common in all programming languages, and they are an essential part of creating web and desktop applications.
'McIntyre If Statements
Public Class Form1  
   Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load  
     Dim number, digits As Integer  
     Dim myString As String  
     number = 53  
     If number < 10 Then  
       digits = 1  
     End If  
     If digits = 1 Then  
       myString = "One"  
     Else : myString = "More than one"  
     End If  
     If number < 100 Then  
       digits = 2  
     ElseIf number > 100 Then  
       digits = 3  
     Else  
       MessageBox.Show("No")  
     End If  
   End Sub  
 End Class  

No comments:

Post a Comment

Classes

Programming II

Advanced Relational Database

Followers