- UID
- 524530
- 积分
- 0
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2006-12-4
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
我刚入门EXCEL VBA编程,现在碰到个题目想请教大家:
1.求一组数,它除3余2,除5余3,除7余2,求满足上面要求的所有数[1,100]
2.求所有两位数,该数要满足:这个数的平方数的各个位数之和是原数的一半。如18*18=324, 3+2+4=9,9=18/2
3.然后再把这些数从小到大冒泡排列,要求在一个模块中编程
这是我编的3个单独的程序:
1.
Sub main()
Dim i As Integer
For i = 1 To 100
If i Mod 3 = 2 And i Mod 5 = 3 And i Mod 7 = 2 Then
Debug.Print i
End If
Next
End Sub
2.
Private Sub Form_Click()
Dim i As Integer
Dim j As Integer
Dim b(1 To 4) As Integer
Dim s As Integer
Dim k As Integer
For i = 10 To 99
j = i * i
b(1) = j \ 1000 Mod 10
b(2) = j \ 100 Mod 10
b(3) = j \ 10 Mod 10
b(4) = j Mod 10
s = 0
For k = 1 To 4
s = s + b(k)
Next k
If s * 2 = i Then
Debug.Print i
End If
Next
End Sub
3.
Option Explicit
Sub main()
Dim i As Integer
Dim j As Integer
Dim temp As Integer
Dim flag As Boolean
Dim a(1 To 7) As Integer
a(1) = 8
a(2) = 5
a(3) = 11
a(4) = 9
a(5) = 2
a(6) = 7
a(7) = 6
For i = 1 To 7
flag = False
For j = i + 1 To 7
If a(j) < a(i) Then
temp = a(i)
a(i) = a(j)
a(j) = temp
flag = True
End If
Next
If flag = False Then
Exit For
End If
Next
For i = 1 To 7
Debug.Print "a(" & i & ")=" & a(i)
Next
End Sub
以上是3个分开的程序,要求在同一个模块中执行(如题),望高人指点,小弟感激不尽 |
|