SOS:请高手帮我解决一个vb题目,考试要交的,急。非常感谢各位了!!!

2024-12-14 08:18:58
推荐回答(4个)
回答1:

Private Sub Form_Click()
'第一题
Dim i As Integer, S As Long
For i = 1 To 10
S = S + (i + 1) * (2 * i + 1)
Next
Print S
End Sub

Private Sub Command1_Click()
'第二题,你的是对的
Dim i%, j3%, j7%
For i = 1 To 100
If i Mod 3 = 0 Then j3 = j3 + 1
If i Mod 7 = 0 Then j7 = j7 + 1
Next
Print "3的倍数的个数:"; j3
Print "7的倍数的个数:"; j7
End Sub

Private Sub Command1_Click()
'第三题
Dim s As String
s = InputBox("请输入一个字符串:")
Print "原字符串为:"; s
Print "新字符串为:"; StrReverse(s)
End Sub

回答2:

dim i,n,m as integer
n=0:m=0
for i=1 to 100
if i mod 3=0 then n=n+1
if i mod 7=0 then m=m+1
next
print "3的倍数的个数是:" n "个"
print "7的倍数的个数是:" m "个"
----------------------------------
反向:如:在textbox中输入文本
dim s,n,m as string
dim i as integer
s=text1.text:n=""
for i=len(s) to 1 step -1
n=n+mid(s,i,1)
next
text1.text="反响后字符为:" & n

回答3:

反序
Dim str As String
Dim I As Integer
Dim str1 As String
str = Text1.Text
For I = 0 To Len(str) - 1
str1 = str1 + Mid(str, Len(str) - I, 1)
Next I
Text2.Text = str1
End Sub

回答4:

哈哈,好复杂!!不懂!