用VB编程:输入英文单词,按A到Z排列
画两个文本,一个按键,名字取默认,转换,我字母是按ASCII编码排列大小,如有大写的改成小写的,或者你把代码改下,,有点忘了,该代码经测试可以了,
PrivatESubCommand1_Click()
DimaAsInteger
Dimb(100)AsString
a=Len(Text1.Text)
DimxAsInteger
Forx=1Toa
b(x)=qz(Text1.Text,x)
Nextx
-------------------------冒泡排列--------------------------------
DimkAsInteger
DimtempAsString
Forl=1Toa-1
Fork=1Toa-1
IfAsc(b(k))>Asc(b(k+1))Then
temp=b(k)
b(k)=b(k+1)
b(k+1)=temp
EndIf
Nextk
Nextl
Forl=1Toa
Text2.Text=Text2.Text+b(l)
Nextl
EndSub
PublicFuNCTionqz(kkAsString,bbAsInteger)AsString自已定义的提取字符函数
DimaAsString
a=Left(kk,bb)
qz=Right(a,1)
EndFunction
PrivateSubForm_Load()
Text1.Text="请输入你要排列的单词"
Text2.Text=""
Command1.Caption="排列"
EndSub
本回答由网友推荐
用vb+编程两个单词如果包含相同的字母,次序不同?
FunctionIsAnagram(strAAsString,strBAsString)
strA=LCase(strA)
strB=LCase(strB)
If(StrComp(strA,strB,1)=0)Or(Len(strA)<>Len(strB))Then
IsAnagram=False
ExitFunction
EndIf
DimcountA(25)AsInteger
DimcountB(25)AsInteger
DimiAsInteger
Fori=1ToLen(strA)
countA(Asc(Mid(strA,i,1))-97)=countA(Asc(Mid(strA,i,1))-97)+1
countB(Asc(Mid(strB,i,1))-97)=countB(Asc(Mid(strB,i,1))-97)+1
DimflagAsBoolean
flag=True
Fori=0To25
IfcountA(i)<>countB(i)Then
flag=False
ExitFor
EndIf
IsAnagram=flag
EndFunction
MsgBoxIsAnagram("listen","listen")false
MsgBoxIsAnagram("silent","listen")true
MsgBoxIsAnagram("apple","aplee")false
本回答由网友推荐
求目前所有vb用语
VB所有的单词,高分求
以下是全部的单词网:
e~g: ?ArticleID=1753
h~k: ?ArticleID=1752
l~n: ?ArticleID=1751
o~r: ?ArticleID=1750
s~v: ?ArticleID=1749