VB编程:求字符串中ASCII 码值最大和最小字符的ASCII和所有字符ASCII码值的

2025-04-05 02:22:11
推荐回答(1个)
回答1:

Private Sub Command1_Click()

x = InputBox("请输入一个字符串:")

For i = 1 To Len(x)

c = Mid(x, i, 1)

s = s + Asc(c)

If i = 1 Then

Max = Asc(c)

Min = Asc(c)

Else

If Max < Asc(c) Then Max = Asc(c)

If Min > Asc(c) Then Min = Asc(c)

End If

Next i

Print x

Print "其中的ASCII最大值="; Max; " 最小值="; Min

Print "所有字符的ASCII总值="; s

End Sub