VB编程题目
1.通过Inputbox函数输入一个正整数K,编程求K的各位数字之和,并用Msgbox函数输出。2.判断某一正整数是否为回文数。所谓回文数是指左右数字完全对称的自然数。例...
1.通过Inputbox函数输入一个正整数K,编程求K的各位数字之和,并用Msgbox函数输出。2.判断某一正整数是否为回文数。所谓回文数是指左右数字完全对称的自然数。例如:121;12321;484;555;2992等都是回文数。3.随机产生10个两位数,查找其中最大的能被3整除的数,如果没有则显示“无要找的数”。例如,37﹑70﹑42﹑44﹑72﹑58﹑91﹑52﹑42﹑11中72就是最大的能被3整除的数。
展开
4个回答
2013-06-18
展开全部
Private Sub Command1_Click()
Dim k%, sum%
sum = 0
k = Val(Trim(InputBox("请输入正整数k的值")))
For i = 1 To Len(Str(k))
sum = sum + Val(Mid(Str(k), i, 1))
Next i
MsgBox sum
End SubPrivate Sub Command2_Click()
Dim s
s = InputBox("请输入一个正整数")
If StrReverse(s) = s Then
MsgBox s & "是回文数"
Else
MsgBox s & "不是回文数"
End If
End SubPrivate Sub Command3_Click()
Dim max%, a(1 To 10) As Integer
Randomize
max = 0
For i = 1 To 10
a(i) = Int(10 + Rnd * 90)
If max < a(i) And a(i) Mod 3 = 0 Then max = a(i)
Next i
If max > 0 Then
MsgBox max
Else
MsgBox "无要找的数"
End If
End Sub
Dim k%, sum%
sum = 0
k = Val(Trim(InputBox("请输入正整数k的值")))
For i = 1 To Len(Str(k))
sum = sum + Val(Mid(Str(k), i, 1))
Next i
MsgBox sum
End SubPrivate Sub Command2_Click()
Dim s
s = InputBox("请输入一个正整数")
If StrReverse(s) = s Then
MsgBox s & "是回文数"
Else
MsgBox s & "不是回文数"
End If
End SubPrivate Sub Command3_Click()
Dim max%, a(1 To 10) As Integer
Randomize
max = 0
For i = 1 To 10
a(i) = Int(10 + Rnd * 90)
If max < a(i) And a(i) Mod 3 = 0 Then max = a(i)
Next i
If max > 0 Then
MsgBox max
Else
MsgBox "无要找的数"
End If
End Sub
2013-06-18
展开全部
Private Sub Command1_Click()
Dim k, s As Integer
k = Val(InputBox("k="))
For i = 1 To Len(Trim(Str(k)))
s = s + Val(Mid(Trim(Str(k)), i, 1))
Next i
MsgBox s
End SubPrivate Sub Command2_Click()
Dim b, l
b = InputBox("b=")
l = IIf(Len(Trim(Str(b))) Mod 2 = 0, Len(Trim(b)) / 2, Len(Trim(b)) \ 2)
If Mid(Trim(b), 1, l) = StrReverse(Right(Trim(b), l)) Then
MsgBox b & " yes"
Else
MsgBox b & " no"
End If
End SubPrivate Sub Command3_Click()
Dim c(1 To 10) As Integer, max As Integer
Randomize
max = 0
For i = 1 To 10
c(i) = Int(10 + Rnd * 90)
If max < c(i) And c(i) Mod 3 = 0 Then max = c(i)
Print c(i);
Next i
Print
If max > 0 Then
MsgBox max
Else
MsgBox "无要找的数"
End If
End Sub
Dim k, s As Integer
k = Val(InputBox("k="))
For i = 1 To Len(Trim(Str(k)))
s = s + Val(Mid(Trim(Str(k)), i, 1))
Next i
MsgBox s
End SubPrivate Sub Command2_Click()
Dim b, l
b = InputBox("b=")
l = IIf(Len(Trim(Str(b))) Mod 2 = 0, Len(Trim(b)) / 2, Len(Trim(b)) \ 2)
If Mid(Trim(b), 1, l) = StrReverse(Right(Trim(b), l)) Then
MsgBox b & " yes"
Else
MsgBox b & " no"
End If
End SubPrivate Sub Command3_Click()
Dim c(1 To 10) As Integer, max As Integer
Randomize
max = 0
For i = 1 To 10
c(i) = Int(10 + Rnd * 90)
If max < c(i) And c(i) Mod 3 = 0 Then max = c(i)
Print c(i);
Next i
If max > 0 Then
MsgBox max
Else
MsgBox "无要找的数"
End If
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-06-18
展开全部
不搞vb关注下
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-06-18
展开全部
手机关注、回来没被解决的话,上电脑给贴代码
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询