Case , :
Select Case
intTest
Case 1 To 5, 10 To 15, 21
'
End Select
:
Select Case
strTest
Case "esh1", "esh2"
msgbox("Found esh 1 or 2")
Case "esh3"
msgbox("Found esh 3")
End Select
Dim Number As Integer = 8
' ...
Select Number ' Evaluate Number.
Case 1 To 5 ' Number between 1 and 5, inclusive.
Debug.WriteLine("Between 1 and 5")
' The following is the only Case clause that evaluates to True.
Case 6, 7, 8 ' Number between 6 and 8.
Debug.WriteLine("Between 6 and 8")
Case 9 To 10 ' Number is 9 or 10.
Debug.WriteLine("Greater than 8")
Case Else ' Other values.
Debug.WriteLine("Not between 1 and 10")
End Select
Dim Check As Boolean = True
Dim Counter As Integer = 0
Do ' Outer loop.
Do While Counter < 20 ' Inner loop.
Counter += 1 ' Increment Counter.
If Counter = 10 Then ' If condition is True,
Check = False ' Set value of flag to False.
Exit Do ' Exit inner loop.
End If
Loop
Loop Until Check = False ' Exit outer loop immediately.
Dim Counter As Integer = 0
While Counter < 20 ' Test value of Counter.
Counter += 1 ' Increment Counter.
End While ' End While loop when Counter > 19.
Debug.WriteLine (Counter) ' Prints 20 in the Output window.For... Next (counter) e , , . start. , end. Step . , 1. step , . - end. , For 10 , Val 5:
For I As Integer = 1 To 10
For J As Integer = 1 To 10
For K As Integer = 1 To 10
' I, J, K.
Next K
Next J
Next I
Dim Words, Digit As Integer
Dim MyString As String
For Words = 10 To 1 Step -1 ' 10 .
For Digit = 0 To 9 ' 10 .
MyString = MyString & CStr(Digit) ' .
Next Digit ' .
MyString = MyString & " " ' .
Next Words
Dim Found As Boolean = False
Dim MyCollection As New Collection
For Each MyObject As Object In MyCollection ' .
If CStr(MyObject.Text) = "Hello" Then ' Text "Hello"
Found = True ' Found True.
Exit For ' .
End If
Next
Dim AlertLabel As New System.Windows.Forms.Label
' ...
Sub AlertUser(ByVal Value As Long)
With AlertLabel
If Value = 0 Then
.ForeColor = Color.Red
.Font = New Font(.Font, FontStyle.Bold Or FontStyle.Italic)
Else
.Forecolor = Color.Black
.Font = New Font(.Font, FontStyle.Regular)
End If
End With
End Sub
Sub MyInput()
With Workbooks("Book1").Worksheets("Sheet1").Cells(1, 1)
.Formula = "=SQRT(50)"
With .Font
.Name = "Arial"
.Bold = True
.Size = 8
End With
End With
End Sub
With MyLabel
.Height = 2000
.Width = 2000
.Text = "This is MyLabel"
End With
With MyObject
.Height = 100 ' MyObject.Height = 100.
.Text = "Hello World" ' MyObject.Text = "Hello World".
.ForeColor = Color.Green ' MyObject.ForeColor = Color.Green.
.Font = New Font(.Font, FontStyle.Bold) ' :
' MyObject.Font = New Font(MyObject.Font, FontStyle.Bold).