vb程序设计代码完善:编制程序从输入的字符串中删除重复出现的字母(小写字母需转换为大写字母)
然后在列表框中降序显示所有出现的字母OptionBase1OptionExplicitPrivateSubCommand1_Click()Dima(26)AsIntege...
然后在列表框中降序显示所有出现的字母
Option Base 1
Option Explicit
Private Sub Command1_Click()
Dim a(26) As Integer, i As Integer, s As String
Dim t As String, idx As Integer, s1 As String
s = UCase(Text1)
For i = 1 To Len(s)
t = Mid(s, i, 1)
If Then
If a(idx) <> 1 Then
s1 = s1 & t
End If
Else
s1 = s1 & t
End If
Next i
Text2 = s1
For i = 26 To 1 Step -1
If a(i) = 1 Then List1.AddItem Chr(Asc("a") + i - 1)
Next i
End Sub 展开
Option Base 1
Option Explicit
Private Sub Command1_Click()
Dim a(26) As Integer, i As Integer, s As String
Dim t As String, idx As Integer, s1 As String
s = UCase(Text1)
For i = 1 To Len(s)
t = Mid(s, i, 1)
If Then
If a(idx) <> 1 Then
s1 = s1 & t
End If
Else
s1 = s1 & t
End If
Next i
Text2 = s1
For i = 26 To 1 Step -1
If a(i) = 1 Then List1.AddItem Chr(Asc("a") + i - 1)
Next i
End Sub 展开
2个回答
展开全部
Option Base 1
Option Explicit
Private Sub Command1_Click()
Dim a(26) As Integer, i As Integer, s As String
Dim t As String, j As Integer
s = UCase(Text1)
i = 1
While i < Len(s)
t = Mid(s, i, 1)
If t >= "A" And t <= "Z" Then
a(Asc(t) - Asc("A") + 1) = 1
j = i + 1
While j <= Len(s)
If Mid(s, j, 1) = t Then
s = Left(s, j - 1) & Mid(s, j + 1)
Else
j = j + 1
End If
Wend
End If
i = i + 1
Wend
Text2 = s
For i = 26 To 1 Step -1
If a(i) = 1 Then List1.AddItem Chr(Asc("A") + i - 1)
Next i
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询