VB.NET自加写法+=

直接看代码

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim a As Integer = 0

        '单次自加
        a += 1
        MsgBox(a)

        '循环自加
        For a = 1 To 10
        Next
        MsgBox(a)
    End Sub

以上代码输出结果为1和11如下图

如需自减则为a-=1,for 中加入step -1



微信扫描下方的二维码阅读本文