1. ç¼ç¨å¨çªä½ä¸è¾åº101~500ä¹é´çææè½è¢«3æè
7æ´é¤çå¥æ°ï¼æç
§ä¸è¡5个çæ¹å¼è¾åºå¹¶æå符åè¦æ±çæ°çåã
解ï¼ä»£ç 为
Private Sub form_load()
Show
Dim n, sum As Integer
Print Spc(6); "101~500ä¹é´çææè½è¢«3æè
7æ´é¤çå¥æ°,ååæ°çå"
i = 0
sum = 0
For n = 101 To 500 Step 2
If n Mod 3 = 0 Or n Mod 7 = 0 Then
sum = sum + n
i = i + 1
Print Spc(6); n;
If i Mod 5 = 0 Then
Print
End If
End If
Next n
Print Spc(7); "sum="; sum
End Sub
2. å¨4个TextBoxä¸è¾å
¥4个大å°ä¸åçæ°ï¼å°å®ä»¬ä»å¤§å°å°æåºåçç»æç¨Msgboxå½æ°è¾åºã
è§£ï¼ ä»£ç 为
Private Sub Command1_Click()
Dim a!, b!, c!, d!
a = Val(Text1.Text)
b = Val(Text2.Text)
c = Val(Text3.Text)
d = Val(Text4.Text)
If a <> b And b <> c And c <> d And a <> c And a <> d And b <> d Then
If a < b Then
t = a: a = b: b = t
End If
If a < c Then
t = a: a = c: c = t
End If
If b < c Then
t = b: b = c: c = t
End If
If d > a Then
t = d: d = a: a = t
End If
If d > b Then
t = d: d = b: b = t
End If
If d > c Then
t = d: d = c: c = t
End If
MsgBox "ä»å¤§å°å°æåºï¼" & a & "," & b & "," & c & "," & d
Else
MsgBox "æç¸åçæ°"
End If
End Sub
Private Sub Command2_Click()
End
End Sub
3. å¨TextBoxä»»æè¾å
¥xçå¼ï¼å°f(x)è¾åºçç»æç¨Msgboxå½æ°è¾åºã
è§£ï¼ ä»£ç 为
Private Sub Command1_Click()
Dim x As Double
x = Val(Text1.Text)
If x < 0 Then
If x = -3 Then
MsgBox "f(x)=" & x ^ 2 - x - 1
Else: MsgBox "f(x)=" & x ^ 2 + x - 6
End If
End If
If x >= 0 Then
If x < 10 And x <> 2 And x <> 3 Then
MsgBox "f(x)=" & x ^ 2 - 5 * x + 6
Else: MsgBox "f(x)=" & x ^ 2 - x - 1
End If
End If
End Sub
Private Sub Command2_Click()
End
End Sub
4. æ¾å°10000å°99999ä¸çææåææ°ï¼å¹¶æç
§ä¸è¡10个çæ ¼å¼å¨çªä½ä¸è¾åºï¼ä¾å¦12321æ¯åææ°ï¼ä¸ªä½ä¸ä¸ä½ç¸åï¼åä½ä¸åä½ç¸åã
解ï¼ä»£ç 为
Private Sub Form_Load()
Show
Dim x, a, b, c, d, e As Integer
Print Spc(25); "ææçäºä½åææ°ï¼"
Print
i = 0
For x = 10000 To 99999
a = x \ 10000
b = (x - (a * 10000)) \ 1000
c = (x - (a * 10000) - (b * 1000)) \ 100
d = (x - (a * 10000) - (b * 1000) - (c * 100)) \ 10
e = x - (a * 10000) - (b * 1000) - (c * 100) - (d * 10)
If a = e And b = d And c <> a And c <> b And a <> b Then
Print Spc(5); x;
i = i + 1
If i Mod 10 = 0 Then
Print
End If
End If
Next
End Sub
5. å¨çªä½ä¸è¾åºææçâæ°´ä»è±æ°âï¼å¹¶æç
§ä¸è¡5个çæ ¼å¼è¾åºãæè°âæ°´ä»è±æ°âæ¯æä¸ä¸ªä¸ä½æ°ï¼å
¶åä½æ°åç«æ¹åçäºè¯¥æ°æ¬èº«ãä¾å¦ï¼153æ¯ä¸ä¸ªâæ°´ä»è±æ°âï¼å 为153=1*1*1ï¼5*5*5ï¼3*3*3ã
解ï¼ä»£ç 为
Private Sub form_load() Show Dim a, b, c, i As Integer Print Spc(10); "æ°´ä»è±æ°" For i = 100 To 999 a = i Mod 10 b = i \ 100 c = (i - b * 100) \ 10 If a ^ 3 + b ^ 3 + c ^ 3 = i Then Print i; Space(2); If (i + 1) Mod 5 = 0 Then Print End If End If Next i End Sub
6. ç¼ç¨æ¾åºæ»¡è¶³ä¸åæ¡ä»¶çææåä½æ°å¹¶å¨çªä½ä¸æç
§ä¸è¡10个çå½¢å¼è¾åºï¼è¯¥æ°ç¬¬ä¸ãä¸ä½æ°åä¹å为10ï¼ç¬¬äºãåä½æ°åä¹ç§¯ä¸º12ã
解ï¼ä»£ç 为
Private Sub Form_Load()
Dim i As Integer, a(1 To 4) As Integer, j As Integer
j = 0
Show
For i = 1000 To 9999
a(1) = i Mod 10
a(2) = ((i - a(1)) / 10) Mod 10
a(3) = ((i - i Mod 100) / 100) Mod 10
a(4) = ((i - i Mod 1000) / 1000) Mod 10
If (a(4) + a(2) = 10 And a(1) * a(3) = 12) Then
Print Tab((j Mod 10 + 1) * 7);
Print i;
j = j + 1
If (j Mod 10 = 0) Then Print
End If
Next
End Sub
7.ç¼åä¸ä¸ªç¨åºï¼å¨2个TextBoxä¸è¾å
¥æ人ç身é«ï¼cmï¼åä½éï¼kgï¼ï¼æä¸å¼ç¡®å®å
¶ä½éæ¯å¦ä¸ºæ åãè¿èæè¿ç¦ï¼å°ç»æç¨Msgboxè¾åºãï¼1ï¼æ åä½é=身é«-110ï¼ï¼2ï¼è¶
è¿æ åä½é5kg为è¿èï¼ï¼3ï¼ä½äºæ åä½é5kg为è¿ç¦ã
è§£ï¼ ä»£ç 为
Private Sub Command1_Click()
Dim a, b, c As Single
a = Val(Text1.Text)
b = Val(Text2.Text)
c = a - 110
If b - c > 5 Then
MsgBox "ä½éè¿è"
ElseIf c - b > 5 Then
MsgBox "ä½éè¿ç©"
ElseIf c - b <> 5 Or c - b = 5 Then
MsgBox "æ åä½é"
End If
End Sub
Private Sub Command2_Click()
End
End Sub
8.å¨TextBoxä¸è¾å
¥ä¸ä¸ªæ£æ´æ°nï¼è®¡ç® çå¼å¹¶å¨çªä½ä¸è¾åºç»æã
è§£ï¼ ä»£ç 为
Private Sub Command1_Click()
Dim n, f, s, i As Integer
n = Val(Text1.Text)
f = 1
s = 0
For i = 1 To n
f = f * i
s = s + f / (i + 2)
Next i
Label2.Caption = "S=" & s
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Form_Load()
End Sub
9.å·²ç¥abcd+dcba=3456ï¼å
¶ä¸aï¼bï¼cï¼då为ä¸ä½æ£æ´æ°ï¼ç¼ç¨æ±åºæ»¡è¶³æ¡ä»¶çaï¼bï¼cï¼dææç»åï¼å¨Labelä¸è¾åºçæ¡ã
è§£ï¼ ä»£ç 为
Private Sub Command1_Click()
Dim a, b, c, d, i As Integer
i = 0
For a = 0 To 9
For b = 0 To 9
For c = 0 To 9
For d = 0 To 9
If (a * 1000 + b * 100 + c * 10 + d + d * 1000 + c * 100 + b * 10 + a = 3456) Then
Label1.Caption = "a=" & a & "," & "b=" & b & "," & "c=" & c & "," & "d=" & d
i = i + 1
Else
Label1.Caption = "没æè¿æ ·çæ°"
End If
Next
Next
Next
Next
End Sub
10.ç¼ç¨è¾åºææ满足å¦ä¸æ¡ä»¶çä¸ä½æ£æ´æ°ï¼å®æ¯ææ´æ°çå¹³æ¹ï¼å®çä¸ä½æ°ç æ两ä½æ¯ç¸åçï¼å¨çªä½ä¸æç
§ä¸è¡5个çæ ¼å¼è¾åºãï¼å¦100æ¯10çå¹³æ¹ï¼å®æ两个0ï¼225æ¯15çå¹³æ¹ï¼å®æ两个2ï¼ã
解ï¼ä»£ç 为
Private Sub Form_Load()
Show
Dim x, a, b, c, m As Integer
Print Tab(10); "ææçä¸ä½æ°ï¼"
Print
i = 0
For x = 100 To 999
For m = 10 To 32
a = x \ 100
b = (x - (a * 100)) \ 10
c = x - (a * 100) - (b * 10)
If a = b Or b = c Or c = a Then
If x = m * m Then
Print Spc(5); x;
i = i + 1
If i Mod 5 = 0 Then
Print
End If
End If
End If
Next m
Next x
End Sub
11.æ±è¿æ ·ä¸ä¸ªåä½æ°å¹¶è¾åºè¯¥æ°åï¼è¯¥åä½æ°çäºå
¶æ¯ä½æ°åçé¶ä¹ä¹åãå³ï¼
abcd = a! + b! + c! + d!ï¼å°ç»æç¨Msgboxå½æ°è¾åºã
è§£ï¼ ä»£ç 为
Private Sub Command1_Click()
Dim i As Integer, a(1 To 4) As Integer, j As Integer
j = 0
For i = 1000 To 9999
a(1) = i Mod 10
a(2) = ((i - a(1)) / 10) Mod 10
a(3) = ((i - i Mod 100) / 100) Mod 10
a(4) = ((i - i Mod 1000) / 1000) Mod 10
If (i = fact(a(1)) + fact(a(2)) + fact(a(3)) + fact(a(4))) Then
MsgBox ("å
¶ä¸ä¸ä¸ªåä½æ°ä¸ºï¼" & i)
j = j + 1
End If
Next
If j = 0 Then MsgBox ("æ ç»æ")
End Sub
Private Function fact(n As Integer) As Long
Dim i As Integer
f = 1
For i = 1 To n
f = f * i
Next
fact = f
End Function
12.è¾åºææ大äº1010ç4ä½å¶æ°ï¼ä¸è¯¥ç±»å¶æ°çåä½æ°å两两ä¸ç¸åï¼å¨çªä½ä¸æç
§ä¸è¡5个çæ ¼å¼è¾åºã
解ï¼ä»£ç 为
Private Sub form_load()
Show
Dim a, b, c, d As Integer
Print Tab(20); "ææçåä½æ°ï¼"
i = 0
For x = 1010 To 9999 Step 2
a = x \ 1000
b = (x - (a * 1000)) \ 100
c = (x - (a * 1000) - (b * 100)) \ 10
d = x - (a * 1000) - (b * 100) - (c * 10)
If a <> b And b <> c And c <> a And a <> d And b <> d And c <> d Then
Print Spc(5); x;
i = i + 1
If i Mod 5 = 0 Then
Print
End If
End If
Next
End Sub
13.æ±1-2!+3!-4!...åºåï¼å½æåçç»æè¶
è¿2000000åæ¢è®¡ç®ï¼å°è¯¥åºåçæç»æç¨Msgboxå½æ°è¾åºã
è§£ï¼ ä»£ç 为
Private Function m(n As Double) As Double
Dim i As Double
f = 1
For i = 1 To n
f = f * i
Next
m = f
End Function
Private Sub Command1_Click()
Dim i As Integer, b As Double, j As Double
b = 0
i = 1
j = 1
Do While (b < 2000000)
b = b + i * m(j)
j = j + 1
i = i * (-1)
Loop
MsgBox ("ç»æ为ï¼" & b)
End Sub
14.ä¸ä½å¸æºé
驾æ人éè·ãç°åºä¸äººç®å»äºä»¶ï¼ä½é½æ²¡è®°ä½è½¦å·ï¼åªè®°ä¸è½¦å·çä¸äºç¹å¾ãç²è¯´ï¼çç
§çå两ä½æ°åæ¯ç¸åçï¼ä¹è¯´ï¼çç
§çå两ä½æ°åæ¯ç¸åçï¼ä¸æ¯ä½æ°å¦å®¶ï¼ä»è¯´ï¼åä½ç车å·å好æ¯ä¸ä¸ªæ´æ°çå¹³æ¹ãè¯·æ ¹æ®ä»¥ä¸çº¿ç´¢æ±åºè½¦å·ãï¼è½¦å·ä¸º4ä½æ£æ´æ°ï¼ç»æå¨TextBoxä¸è¾åºï¼
è§£ï¼ ä»£ç 为
Private Sub Form_Load()
Dim i As Integer, j As Integer, a(1 To 4) As Integer
j = 0
Show
For i = 1000 To 9999
a(1) = i Mod 10
a(2) = ((i - a(1)) / 10) Mod 10
a(3) = ((i - i Mod 100) / 100) Mod 10
a(4) = ((i - i Mod 1000) / 1000) Mod 10
If (Sqr(i) - Fix(Sqr(i)) = 0) Then
If (a(1) = a(2) And a(3) = a(4)) Then
Text1.Text = i
End If
End If
Next
End Sub
15.ç¨æ·å©ç¨InputBoxå½æ°éæºè¾å
¥12个0ï¼100ä¹é´çæ´æ°ï¼ç»è®¡åºå°äº60ï¼60å°70ï¼70å°80ï¼80å°90以å90å°100èå´çæ´æ°åæå¤å°ä¸ªï¼ç¨Msgboxå½æ°æ¾ç¤ºè¾åºç»æã
è§£ï¼ ä»£ç 为
Private Sub Command1_Click()
Dim a(1 To 12) As Integer, b(1 To 5) As Integer, i As Integer
For i = 1 To 12
a(i) = Val(InputBox("请è¾å
¥ç¬¬" & i & "个æ°"))
Next
For i = 1 To 12
Select Case a(i)
Case 0 To 59
b(1) = b(1) + 1
Case 60 To 69
b(2) = b(2) + 1
Case 70 To 79
b(3) = b(3) + 1
Case 80 To 90
b(4) = b(4) + 1
Case 90 To 100
b(5) = b(5) + 1
Case Else
End Select
Next
MsgBox ("å°äº60ï¼" & b(1) & "ï¼60å°70ï¼" & b(2) & "ï¼70å°80ï¼" & b(3) & "ï¼80å°90ï¼" & b(4) & "ï¼90å°100ï¼" & b(5))
End Sub
16.å¨TextBoxä¸è¾å
¥ä¸ä¸ªæ£æ´æ°nï¼å½nçå¼ä¸ºå¶æ°æ¶ï¼æ±1-1/2-1/4-...-1/nåºåçåï¼å½n为å¥æ°æ¶ï¼æ±1-1/3-1/5...-1/nåºåçåï¼å°ç»æç¨Msgboxå½æ°è¾åºã
è§£ï¼ ä»£ç 为
Private Sub Command1_Click()
Dim a As Integer, b As Double, x As Double
a = Val(Text1.Text)
x = 1
Select Case a Mod 2
Case 0
For b = 2 To a Step 2
x = x - 1 / b
Next
Case 1
For b = 3 To a Step 2
x = x - 1 / b
Next
Case Else
End Select
MsgBox ("ç»æ为ï¼" & Format(x, "0.#####"))
End Sub
17.ç¼å¶ç¨åºè¦æ±è¾å
¥æ´æ°aåbï¼è¥a2+b2大äº100ï¼åè¾åºa2+b2ç¾ä½ä»¥ä¸çæ°åï¼å¦åè¾åºä¸¤æ°åä¹åãç»æå©ç¨Msgboxå½æ°è¾åº ã
è§£ï¼ ä»£ç 为
Private Sub Command1_Click()
Dim a As Long, b As Long, s As Long, n As Long
a = Val(Text1.Text)
b = Val(Text2.Text)
s = a ^ 2 + b ^ 2
n = a + b
If s > 100 Then
i = MsgBox("ç»æ为ï¼" & Int(s / 100))
Else: i = MsgBox("ç»æ为ï¼" & n)
End If
End Sub
Private Sub Command2_Click()
End
End Sub
18.çæ°æ¸¸æï¼ç±è®¡ç®æºéæºäº§çä¸ä¸ª2ä½æ£æ´æ°è®©äººæ¥çï¼åªè½ç8次ï¼å¦æ人ç对äºï¼åå©ç¨Msgboxå½æ°æ¾ç¤ºè®¡ç®æºéæºäº§çç该2ä½æ£æ´æ°å¹¶æ¾ç¤ºâYou are so cleverâï¼å¦åå©ç¨Msgboxå½æ°ç»åºæ示ï¼åè¯äººæççæ°æ¯å¤ªå¤§è¿æ¯å¤ªå°ï¼ç´å°äººç对为æ¢ï¼æè
8次é½çä¸å¯¹ç»åºæ示âGame Overâã
è§£ï¼ ä»£ç 为
Private Sub Command1_Click()
Dim a As Integer, b As Integer, i As Integer
Randomize
a = Fix(Rnd(Time) * 90) + 10
For i = 1 To 8
b = Val(InputBox("请è¾å
¥ä¸ä¸ªæ°"))
Select Case b
Case 0 To a - 1
MsgBox ("太å°äºï¼")
Case a + 1 To 100
MsgBox ("太大äºï¼")
Case a
MsgBox ("You are so clever!")
Exit For
Case Else
MsgBox ("è¾å
¥é误ï¼")
End Select
If (i = 8) Then MsgBox ("GAME OVER!")
Next
End Sub
19.å¾å
µçæ¡ä»¶æ¯ï¼ç·æ§ï¼sexï¼å¹´é¾ï¼ageï¼å¨18~20ä¹é´ï¼èº«é«ï¼sizeï¼å¨1.65米以ä¸ï¼æè
女æ§ï¼sexï¼å¹´é¾ï¼ageï¼å¨16~18ä¹é´ï¼èº«é«ï¼sizeï¼å¨1.60米以ä¸ã
ç¨ä¸ä¸ªææ¬æ¡æ§ä»¶åå«è¾å
¥æ§å«ãå¹´é¾ã身é«ä¿¡æ¯ï¼æ ¹æ®è¿äºä¿¡æ¯å¤ææ¯å¦ç¬¦åå¾å
µæ¡ä»¶ï¼ç¨Msgboxå½æ°è¾åºç»æã
è§£ï¼ ä»£ç 为
Private Sub Command1_Click()
Dim i As String, j As Single, k As Integer
i = Text1.Text
j = Val(Text2.Text)
k = Val(Text3.Text)
Show
Print i
Select Case i
Case "ç·"
If (k >= 18 And k <= 20) Then
If (j > 165) Then
MsgBox ("åæ ¼ï¼ç¬¦åå¾å
µæ¡ä»¶")
Else
MsgBox ("ä¸åæ ¼ï¼ä¸ç¬¦åå¾å
µæ¡ä»¶")
End If
Else
MsgBox ("ä¸åæ ¼ï¼ä¸ç¬¦åå¾å
µæ¡ä»¶")
End If
Case "女"
If (k >= 16 And k <= 18) Then
If (j > 160) Then
MsgBox ("åæ ¼ï¼ç¬¦åå¾å
µæ¡ä»¶")
Else
MsgBox ("ä¸åæ ¼ï¼ä¸ç¬¦åå¾å
µæ¡ä»¶")
End If
Else
MsgBox ("ä¸åæ ¼ï¼ä¸ç¬¦åå¾å
µæ¡ä»¶")
End If
Case Else
MsgBox ("è¾å
¥é误ï¼")
End Select
End Sub
Private Sub Command2_Click()
End
End Sub
20.æ±åº1å°1000ä¹å
è½è¢«5æ13æ´é¤ãä½ä¸è½åæ¶è¢«5å13æ´é¤çæææ´æ°ï¼å¨çªä½ä¸æç
§ä¸è¡5个çæ ¼å¼è¾åºã
解ï¼ä»£ç 为
Private Sub Form_Load()
Show
Dim n As Integer
Print Spc(10); "1å°1000ä¹é´è½è¢«5æ13æ´é¤,ä½ä¸è½5å13åæ¶æ´é¤çæææ´æ°:"
i = 0
For n = 1 To 1000
If n Mod 5 = 0 Or n Mod 13 = 0 Then
If n Mod 65 <> 0 Then
i = i + 1
Print Spc(6); Format(n, "!@@@@");
If i Mod 5 = 0 Then
Print
End If
End If
End If
Next
End Sub
温馨提示:内容为网友见解,仅供参考