Private Sub Command1_Click() Dim s As String, i As Integer, n As Integer s = Trim(Text1.Text) Do While i < Len(s) i = i + 1 n = n + Val(Mid(s, i, 1)) Loop If n Mod 9 = 0 Then Print "这个数能被9整除" Else Print "这个数不能被9整除" End If End Sub
Private Sub Command1_Click() Dim i As Integer i = 1 Dim m As Integer Do Until i > Len(Text1.Text) m = CInt(m & Mid(Text1.Text, i, 1)) Mod 9 i = i + 1 Loop Debug.Print IIf(m > 0, "不能整除", "能整除") End Sub