Skip to content
Home ยป VB 6 With Statement

VB 6 With Statement

    The With statement is not a loop, but can be as useful as a loop. In this article, we will discuss about the With statement.

    The syntax for the width statement is given below.

    With object
    [Statements]
    End With

    Example: With Statement

    In the following example, we will use With statement to set some properties of a Textbox control.

    Private Sub Command1_Click()
    With Text1
      .Width = 2500
      .Height = 800
      .Text = "NotesforMsc"
    End With
    End Sub

    In the above example, we can see that the properties of a textbox is changed using With statement when a user clicks the Command1 button.

    Not only textbox control, we can change many other properties of Visual Basic 6 control objects.

    Output: With Statement

    The output of the above program is given below.

    Output - With Statement
    Figure 1 – Output – With Statement