vba作业?

来源:百度知道 编辑:UC知道 时间:2024/06/08 18:45:22
1.输入一行字符,统计其中英文字母、空格、数字和其它字符的个数。

2.有一函数:

X x<1

Y= 2x-1 1<=x<10

3x-11 x>=10

写程序,输入x,输出y值

3.输入5个整数,要求按由小到大的顺序输出。

4.使用Debug.Print 输出下列三角形。

*

* * *

* * * * *

5.有一行密码,是按照下面的规律译成的密码:

A→C a→c

B→D b→d

C→E c→e

... ...

... ...

... ...

即第一个字母编程第三个字母,第i个字母变成第i+2个字母。非字母符号不变,要求输入后通过程序将密码译成原文,并输出密码和原文。
第二题
y=
X ,x<1
2x-1 ,1<=x<10
3x-11 ,x>=10

1.
Sub m(s As String)
Dim i As Integer, l As Integer
Dim letterCount As Integer, numberCount As Integer, spaceCount As Integer, otherCount As Integer

For i = 1 To Len(s)
l = Asc(Mid(s, i, 1))
If l = 32 Then
spaceCount = spaceCount + 1
ElseIf l >= 65 And l <= 90 Or l >= 97 And l <= 122 Then
letterCount = letterCount + 1
ElseIf l >= 48 And l <= 57 Then
numberCount = numberCount + 1
Else
otherCount = otherCount + 1
End If
Next
MsgBox "英文字母" & letterCount & "个,数字" & numberCount & "个,空格" & spaceCount & "个"
End Sub
2.
Sub showX1()
Dim x As Integer, y As Integer
Do
x = InputBox("请输入X的值", "输入一个数(x<1)", "-1")
Loop While x >= 1
y = x
MsgBox y
End Sub

Sub showX2()
Dim x As Integer, y As Integer
x = Inpu