Use If statement in a For statement : If « Statements « VB.Net Tutorial






public class Test
   public Shared Sub Main

        Dim intCounter As Integer
        Dim strString As String = "some silly string"

        For intCounter = 0 To strString.Length - 1
            If strString(intCounter) = "s" Then
                strString = strString.Remove(intCounter, 1)
                strString = strString.Insert(intCounter, "S")
            End If
        Next intCounter
        Console.WriteLine(strString)

   End Sub


End class
Some Silly String








4.1.If
4.1.1.If with And
4.1.2.Use if statement to compare Integer
4.1.3.Nested if statement
4.1.4.Use ElseIf
4.1.5.Else If (Not ELSEIF)
4.1.6.Use If statement in a For statement
4.1.7.ElseIf
4.1.8.Single line vs Multi-line If statement
4.1.9.If statement Short Circuiting
4.1.10.If Short Circuiting with ANDALSO