vb编程 输入26个英文字母,将其放到数组中,输入一个字母,查询字母在数组中的位置,如未查询到,

2024-12-05 01:41:48
推荐回答(1个)
回答1:

Dim ch(26)

Private Sub Command1_Click()
x = InputBox("请输入要查询的字母")
For i = 0 To 25
If UCase(x) = ch(i) Then
MsgBox x & "是数组中第" & i + 1 & "个元素"
Exit For
End If
Next i
End Sub

Private Sub Form_Load()
For i = 0 To 25
ch(i) = Chr(65 + i)
Next i
End Sub