把重复利用的一段代码写成函数,调用即可,给你举个例子:
Private Sub Command1_Click()
dim i,j
j = Format(Dec_to_Bin((i + 65536)), "0000000000000000") '调用函数
End Sub
Public Function Dec_to_Bin(ByVal Dec As Long) As String '重复利用的代码写成函数
Dec_to_Bin = ""
Do While Dec > 0
Dec_to_Bin = Dec Mod 2 & Dec_to_Bin
Dec = Dec \ 2
Loop
End Function