猿问

请问关于Private Sub Command1_Click()的结果

Dim str1 As String, str2 As String
str1 = InputBox("请输入一个字符串")
subf str1, str2
Print str2
End Sub
Sub subf(s1 As String, s2 As String)
Dim temp As String
Static i As Integer
i = i + 1
temp = Mid(s1, i, 1)
If temp <> " " Then subf s1, s2
s2 = s2 & temp
End Sub
Dim str1 As String, str2 As String
str1 = InputBox("请输入一个字符串")
subf str1, str2
Print str2
End Sub
Sub subf(s1 As String, s2 As String)
Dim temp As String
Static i As Integer
i = i + 1
temp = Mid(s1, i, 1)
If temp <> " " Then subf s1, s2
s2 = s2 & temp
End Sub
结果是多少啊,求大神给出详细过程

Smart猫小萌
浏览 496回答 2
2回答

胡说叔叔

Private Sub command1_click() '点击按钮command1产生的事件Dim a(25), b(25), c(25) '声明一维数组a,b,c下标为(0-25)X1 = Replace(Text1.Text, " ", "") 'X1等于文本框Text1的去掉空格后的字符X2 = Replace(Text2.Text, " ", "") 'X2等于文本框Text2的去掉空格后的字符q = Len(X2) 'q等于X2字符的数量Print Len(X2) '在窗口内打印出X2字符的数量For k = 0 To q \ 25 - 1 '循环,k从0到q整除于25减去1次的循环Print Len(X2) '在窗口内打印出X2字符的数量h = 25 * k '对变量h进行赋值为25乘于kFor i = 1 To 25 '内循环,i从1到25, 共25次循环a(i) = Mid(X1, i, 1) '对数组a(1到25)进行赋值,a(1)等于X1的第一个字符,a(2)等于X2的第二个字符......a(25)等于X1的25个字符。b(i) = Mid(X2, i + h + 2 * k, 1) '对数组b(1到25)进行赋值,b(1)等于X2的第1 + h + 2 * k个字符.......b(25)等于X2的第25 + h + 2 * k个字符a(i) = Val(a(i)) '把数组a(1到25)的值转为数字类型b(i) = Val(b(i)) '把数组b(1到25)的值转为数字类型c(i) = a(i) * b(i) '对数组c(1到25)进行赋值c(1)=a(1)*b(1),c(2)=a(2)*b(2)......c(25)=a(25)*b(25)n = n + 1 'n每次循环递加一,这个变量应该是用来计算循环次数的。Print c(i); '在同一行中打印出数组c(1到25)的值Next '结束i内循环Print '每次结束内循环就换行Next '结束k外循环End Sub '结束按钮command1点击过程'请参考。

临摹微笑

一、输出的结果要根据你输入的字符来确定二、代码编写有错误,输出结果:
随时随地看视频慕课网APP
我要回答