vb编写给定一个字符串(只含有大写字母)判断是不是连续字母串
答案:4 悬赏:20 手机版
解决时间 2021-12-30 23:14
- 提问者网友:世勋超人
- 2021-12-30 04:39
vb编写给定一个字符串(只含有大写字母)判断是不是连续字母串
最佳答案
- 五星知识达人网友:低血压的长颈鹿
- 2021-12-30 05:12
Option Explicit
Private Sub Command2_Click()
Dim T As String, TFT As Long
Dim Tl As Long, i As Long
T = InputBox("请输入任何字符,将判断是否为连续大写字符。", "输入")
Tl = Len(T)
If Tl < 1 Then Exit Sub
TFT = 1
For i = 1 To Tl
If Asc(Mid(T, i, 1)) < 65 Or Asc(Mid(T, i, 1)) > 90 Then
TFT = -1
Exit For
End If
Next
MsgBox "输入的内容是:" & Chr(13) & Chr(10) & T & Chr(13) & Chr(10) & Chr(13) & Chr(10) & "上述内容为 " & IIf(TFT = 1, "连续", "非连续") & " 大写字符。"
End Sub
Private Sub Command2_Click()
Dim T As String, TFT As Long
Dim Tl As Long, i As Long
T = InputBox("请输入任何字符,将判断是否为连续大写字符。", "输入")
Tl = Len(T)
If Tl < 1 Then Exit Sub
TFT = 1
For i = 1 To Tl
If Asc(Mid(T, i, 1)) < 65 Or Asc(Mid(T, i, 1)) > 90 Then
TFT = -1
Exit For
End If
Next
MsgBox "输入的内容是:" & Chr(13) & Chr(10) & T & Chr(13) & Chr(10) & Chr(13) & Chr(10) & "上述内容为 " & IIf(TFT = 1, "连续", "非连续") & " 大写字符。"
End Sub
全部回答
- 1楼网友:神也偏爱
- 2021-12-30 07:38
Private Sub Command1_Click()
Dim s As String
Dim t As Boolean
s = InputBox("请输入字母串")
If Len(s) >= 2 Then t = True
For i = 2 To Len(s)
If Asc(Mid(s, i, 1)) - Asc(Mid(s, i - 1, 1)) <> 1 Then t = False
Next i
If t Then
MsgBox "字母串连续"
Else
MsgBox "字母串不连续"
End If
End Sub
- 2楼网友:想偏头吻你
- 2021-12-30 07:14
如果你输入的肯定只有大写字母、而且判断是否是连续字母串、
那么”热心网友”的回答是正确的。
如果你只是判断是不是输入了大写字母、而不判断是否连续、那”sxqiufeng”的回答是OK的。
- 3楼网友:人類模型
- 2021-12-30 06:19
option explicit
private sub command2_click()
dim t as string, tft as long
dim tl as long, i as long
t = inputbox("请输入任何字符,将判断是否为连续大写字符。", "输入")
tl = len(t)
if tl < 1 then exit sub
tft = 1
for i = 1 to tl
if asc(mid(t, i, 1)) < 65 or asc(mid(t, i, 1)) > 90 then
tft = -1
exit for
end if
next
msgbox "输入的内容是:" & chr(13) & chr(10) & t & chr(13) & chr(10) & chr(13) & chr(10) & "上述内容为 " & iif(tft = 1, "连续", "非连续") & " 大写字符。"
end sub
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯