One Instruction Per Line
The accepted practice when writing VBA code is to put one instruction on each line.
This make the code much easier to follow and understand.
Sub DoSomething()
Dim iNumber1 As Integer
Dim iNumber2 As Integer
iNumber1 = 5
iNumber2 = 10
Call MsgBox(iNumber1 + iNumber2)
End Sub
It is possible to have multiple instructions on a single line by using a colon ":" to separate them.
Sub DoSomething()
Dim iNumber1 As Integer: Dim iNumber2 As Integer
iNumber1 = 5: iNumber2 = 10
Call MsgBox(iNumber1 + iNumber2)
End Sub
Or Even:
Sub DoSomething(): Dim iNumber1 As Integer: Dim iNumber2 As Integer: iNumber1 = 5: iNumber2 = 10: Call MsgBox(iNumber1 + iNumber2): End Sub
© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext