问题描述
如题~我现在想在TEXTBOX里面输入一行数字点击按钮后下面会输出相应的字母比如我在上面输入1234下面就会出现ABCD请问高手如何用代码实现最好能详细点的谢谢了!!
解决方案
解决方案二:
PublicClassForm1DimiAsIntegerPrivateSubTextBox1_TextChanged(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesTextBox1.TextChangedDimsAsString=""DimstAsString=""DimstpAsString=""Fori=0ToLen(TextBox1.Text)-1st=TextBox1.Text.Substring(i,1)Ifst="1"Thenstp="a"Ifst="2"Thenstp="b"Ifst="3"Thenstp="c"Ifst="4"Thenstp="d"'........这里你要写全就行了s=s&stpNextTextBox2.Text=sEndSubEndClass
解决方案三:
要是要一个按钮这样写PublicClassForm1DimiAsIntegerPrivateSubTextBox1_TextChanged(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesTextBox1.TextChangedDimsAsString=""DimstAsString=""DimstpAsString=""Fori=0ToLen(TextBox1.Text)-1st=TextBox1.Text.Substring(i,1)Ifst="1"Thenstp="a"Ifst="2"Thenstp="b"Ifst="3"Thenstp="c"Ifst="4"Thenstp="d"s=s&stpNextTextBox2.Text=sEndSubPrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.ClickDimsAsString=""DimstAsString=""DimstpAsString=""Fori=0ToLen(TextBox1.Text)-1st=TextBox1.Text.Substring(i,1)Ifst="1"Thenstp="a"Ifst="2"Thenstp="b"Ifst="3"Thenstp="c"Ifst="4"Thenstp="d"'........这里你要写全就行了s=s&stpNextTextBox2.Text=sEndSubEndClass
解决方案四:
这样写的话如果我输入11本来是应该输出K的但是他会输出11望高手解决
解决方案五:
我反问你一句,113是11,3还是1,13
解决方案六:
那怎么办.....机器不会识别顺序如果中间给他空格这样能识别吗?
解决方案七:
试过了还是不行
解决方案八:
行我做
解决方案九:
谢谢了小弟很菜
解决方案十:
PrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.ClickDims()Dims1()DimstpAsString=""s=Split(TextBox1.Text,",")Fori=0ToLen(TextBox1.Text)-1s1(i)=changesst(s(i))stp=stp&s1(i)NextTextBox2.Text=sEndSubPrivateFunctionchangesst(ByVala)Ifa="1"Thenstp="a"Ifa="2"Thenstp="b"Ifa="3"Thenstp="c"Ifa="4"Thenstp="d"EndFunction
解决方案十一:
以上还要加一行Ifa=""Thenstp=""这样输入空格也行,要不要报错了,不过你还要写全呀,我没写全Ifa="1"Thenstp="a"Ifa="2"Thenstp="b"Ifa="3"Thenstp="c"Ifa="4"Thenstp="d".....
解决方案十二:
恩太感谢你了~卡了好久了
解决方案十三:
TextBox2.Text=s这句会报错说1惟数组无法转换为STRING
解决方案十四:
过来就好,这没什么,你一通也就百有了,就是没有一个认识,有了认识,就很快上手的,我也才接触半个月而已,没什么
解决方案十五:
还有就是定义的FUNCTION里面会说STP未定义
解决方案:
PrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.ClickDims()Dims1()DimstpAsString=""redims(Len(TextBox1.Text)-1)redims1(Len(TextBox1.Text)-1)s=Split(TextBox1.Text,",")Fori=0ToLen(TextBox1.Text)-1s1(i)=changesst(s(i))stp=stp&s1(i)NextTextBox2.Text=sEndSubPrivateFunctionchangesst(ByVala)Ifa="1"Thenstp="a"Ifa="2"Thenstp="b"Ifa="3"Thenstp="c"Ifa="4"Thenstp="d"EndFunction
解决方案:
PrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.ClickDims()Dims1()DimstpAsString=""redims(Len(TextBox1.Text)-1)redims1(Len(TextBox1.Text)-1)s=Split(TextBox1.Text,",")Fori=0ToLen(TextBox1.Text)-1s1(i)=changesst(s(i))stp=stp&s1(i)NextTextBox2.Text=sEndSubPrivateFunctionchangesst(ByVala)Ifa="1"Thenchangesst="a"Ifa="2"Thenchangesst="b"Ifa="3"Thenchangesst="c"Ifa="4"Thenchangesst="d"EndFunction
解决方案:
对不起我这是在网页上做的,没给你测试,
解决方案:
没关系你已经帮了我很大的忙了
解决方案:
还是提示一唯数组的值无法转换为STRING,,?
解决方案:
你把你的代码帖过来,
解决方案:
PublicClassForm13InheritsSystem.Windows.Forms.Form#Region"Windows窗体设计器生成的代码"PublicSubNew()MyBase.New()'该调用是Windows窗体设计器所必需的。InitializeComponent()'在InitializeComponent()调用之后添加任何初始化EndSub'窗体重写dispose以清理组件列表。ProtectedOverloadsOverridesSubDispose(ByValdisposingAsBoolean)IfdisposingThenIfNot(componentsIsNothing)Thencomponents.Dispose()EndIfEndIfMyBase.Dispose(disposing)EndSub'Windows窗体设计器所必需的PrivatecomponentsAsSystem.ComponentModel.IContainer'注意:以下过程是Windows窗体设计器所必需的'可以使用Windows窗体设计器修改此过程。'不要使用代码编辑器修改它。FriendWithEventsTextBox1AsSystem.Windows.Forms.TextBoxFriendWithEventsTextBox2AsSystem.Windows.Forms.TextBoxFriendWithEventsButton1AsSystem.Windows.Forms.Button<System.Diagnostics.DebuggerStepThrough()>PrivateSubInitializeComponent()Me.TextBox1=NewSystem.Windows.Forms.TextBoxMe.TextBox2=NewSystem.Windows.Forms.TextBoxMe.Button1=NewSystem.Windows.Forms.ButtonMe.SuspendLayout()''TextBox1'Me.TextBox1.Location=NewSystem.Drawing.Point(32,24)Me.TextBox1.Name="TextBox1"Me.TextBox1.Size=NewSystem.Drawing.Size(112,21)Me.TextBox1.TabIndex=0Me.TextBox1.Text=""''TextBox2'Me.TextBox2.Location=NewSystem.Drawing.Point(32,104)Me.TextBox2.Name="TextBox2"Me.TextBox2.Size=NewSystem.Drawing.Size(112,21)Me.TextBox2.TabIndex=1Me.TextBox2.Text=""''Button1'Me.Button1.Location=NewSystem.Drawing.Point(32,200)Me.Button1.Name="Button1"Me.Button1.Size=NewSystem.Drawing.Size(56,24)Me.Button1.TabIndex=2Me.Button1.Text="Button1"''Form13'Me.AutoScaleBaseSize=NewSystem.Drawing.Size(6,14)Me.ClientSize=NewSystem.Drawing.Size(292,266)Me.Controls.Add(Me.Button1)Me.Controls.Add(Me.TextBox2)Me.Controls.Add(Me.TextBox1)Me.Name="Form13"Me.Text="Form13"Me.ResumeLayout(False)EndSub#EndRegionDimiAsIntegerPrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.ClickDims()Dims1()DimstpAsString=""ReDims(Len(TextBox1.Text)-1)ReDims1(Len(TextBox1.Text)-1)s=Split(TextBox1.Text,",")Fori=0ToLen(TextBox1.Text)-1s1(i)=changesst(s(i))stp=stp&s1(i)NextTextBox2.Text=sEndSubPrivateFunctionchangesst(ByVala)Ifa=""Thenchangesst=""Ifa="1"Thenchangesst="a"Ifa="2"Thenchangesst="b"Ifa="3"Thenchangesst="c"Ifa="4"Thenchangesst="d"Ifa="5"Thenchangesst="e"Ifa="6"Thenchangesst="f"Ifa="7"Thenchangesst="g"Ifa="8"Thenchangesst="h"Ifa="9"Thenchangesst="i"Ifa="10"Thenchangesst="j"Ifa="11"Thenchangesst="k"Ifa="12"Thenchangesst="l"Ifa="13"Thenchangesst="m"Ifa="14"Thenchangesst="n"Ifa="15"Thenchangesst="o"Ifa="16"Thenchangesst="p"Ifa="17"Thenchangesst="q"Ifa="18"Thenchangesst="r"Ifa="19"Thenchangesst="s"Ifa="20"Thenchangesst="t"Ifa="21"Thenchangesst="u"Ifa="22"Thenchangesst="v"Ifa="23"Thenchangesst="w"Ifa="24"Thenchangesst="x"Ifa="25"Thenchangesst="y"Ifa="26"Thenchangesst="z"EndFunctionEndClass
解决方案:
PublicClassForm13InheritsSystem.Windows.Forms.FormDimiAsIntegerPrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.ClickDims()Dims1()DimstpAsString=""ReDims(Len(TextBox1.Text)-1)ReDims1(Len(TextBox1.Text)-1)s=Split(TextBox1.Text,",")Fori=0ToLen(TextBox1.Text)-1s1(i)=changesst(s(i))stp=stp&s1(i)NextTextBox2.Text=sEndSubPrivateFunctionchangesst(ByVala)Ifa=""Thenchangesst=""Ifa="1"Thenchangesst="a"Ifa="2"Thenchangesst="b"Ifa="3"Thenchangesst="c"Ifa="4"Thenchangesst="d"Ifa="5"Thenchangesst="e"Ifa="6"Thenchangesst="f"Ifa="7"Thenchangesst="g"Ifa="8"Thenchangesst="h"Ifa="9"Thenchangesst="i"Ifa="10"Thenchangesst="j"Ifa="11"Thenchangesst="k"Ifa="12"Thenchangesst="l"Ifa="13"Thenchangesst="m"Ifa="14"Thenchangesst="n"Ifa="15"Thenchangesst="o"Ifa="16"Thenchangesst="p"Ifa="17"Thenchangesst="q"Ifa="18"Thenchangesst="r"Ifa="19"Thenchangesst="s"Ifa="20"Thenchangesst="t"Ifa="21"Thenchangesst="u"Ifa="22"Thenchangesst="v"Ifa="23"Thenchangesst="w"Ifa="24"Thenchangesst="x"Ifa="25"Thenchangesst="y"Ifa="26"Thenchangesst="z"EndFunctionEndClass
解决方案:
解决方案:
PublicClassForm13InheritsSystem.Windows.Forms.FormDimiAsIntegerPrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.ClickDims()Dims1()DimstpAsString=""ReDims(Len(TextBox1.Text)-1)ReDims1(Len(TextBox1.Text)-1)s=Split(TextBox1.Text,",")Fori=0ToLen(TextBox1.Text)-1s1(i)=changesst(s(i))stp=stp&s1(i)NextTextBox2.Text=stpEndSubPrivateFunctionchangesst(ByVala)changesst=""Ifa=""Thenchangesst=""Ifa="1"Thenchangesst="a"Ifa="2"Thenchangesst="b"Ifa="3"Thenchangesst="c"Ifa="4"Thenchangesst="d"Ifa="5"Thenchangesst="e"Ifa="6"Thenchangesst="f"Ifa="7"Thenchangesst="g"Ifa="8"Thenchangesst="h"Ifa="9"Thenchangesst="i"Ifa="10"Thenchangesst="j"Ifa="11"Thenchangesst="k"Ifa="12"Thenchangesst="l"Ifa="13"Thenchangesst="m"Ifa="14"Thenchangesst="n"Ifa="15"Thenchangesst="o"Ifa="16"Thenchangesst="p"Ifa="17"Thenchangesst="q"Ifa="18"Thenchangesst="r"Ifa="19"Thenchangesst="s"Ifa="20"Thenchangesst="t"Ifa="21"Thenchangesst="u"Ifa="22"Thenchangesst="v"Ifa="23"Thenchangesst="w"Ifa="24"Thenchangesst="x"Ifa="25"Thenchangesst="y"Ifa="26"Thenchangesst="z"EndFunctionEndClass
解决方案:
之前试过了但是我一旦输入两位数然后点击的话就会提示索引超出了数组界限。
解决方案:
这行不对,我在调试Fori=0ToLen(TextBox1.Text)-1
解决方案:
恩麻烦你了
解决方案:
这个调试成功了PublicClassForm1InheritsSystem.Windows.Forms.FormDimiAsIntegerPrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.ClickDims()Dims1()DimstpAsString=""ReDims(Len(TextBox1.Text)-1)ReDims1(Len(TextBox1.Text)-1)s=Split(TextBox1.Text,",")Fori=0Tos.Length-1s1(i)=changesst(s(i))stp=stp&s1(i)NextTextBox2.Text=stpEndSubPrivateFunctionchangesst(ByVala)changesst=""Ifa=""Thenchangesst=""Ifa="1"Thenchangesst="a"Ifa="2"Thenchangesst="b"Ifa="3"Thenchangesst="c"Ifa="4"Thenchangesst="d"Ifa="5"Thenchangesst="e"Ifa="6"Thenchangesst="f"Ifa="7"Thenchangesst="g"Ifa="8"Thenchangesst="h"Ifa="9"Thenchangesst="i"Ifa="10"Thenchangesst="j"Ifa="11"Thenchangesst="k"Ifa="12"Thenchangesst="l"Ifa="13"Thenchangesst="m"Ifa="14"Thenchangesst="n"Ifa="15"Thenchangesst="o"Ifa="16"Thenchangesst="p"Ifa="17"Thenchangesst="q"Ifa="18"Thenchangesst="r"Ifa="19"Thenchangesst="s"Ifa="20"Thenchangesst="t"Ifa="21"Thenchangesst="u"Ifa="22"Thenchangesst="v"Ifa="23"Thenchangesst="w"Ifa="24"Thenchangesst="x"Ifa="25"Thenchangesst="y"Ifa="26"Thenchangesst="z"EndFunctionEndClass
解决方案:
这个你可以加一个计时器,侦听,这个文本框的变化,如超过多少多少毫秒自己就加上一个“,”这样就比较完美了,
解决方案:
恩谢谢你了
解决方案:
PrivateSubButton4_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton4.ClickDimsAsString="1,2,3,4,26"Console.WriteLine(GetString(s))EndSubPublicFunctionGetString(ByValvalueAsString)AsStringDimbAsNewSystem.Text.StringBuilderForEachsAsStringInvalue.Split(","c)b.Append(Chr(Integer.Parse(s)+64))NextReturnb.ToStringEndFunction
解决方案:
b.Append(Chr(Integer.Parse(s)+64))这个最好了,accis码1+64就是a了啊
解决方案:
引用31楼lzmtw的回复:
VB.NETcodePrivateSubButton4_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton4.ClickDimsAsString="1,2,3,4,26"Console.WriteLine(GetString(s))EndSubPublicFunctionGetString(ByValvalueAsString)AsStringDimbAsNewSystem.Text.StringBuilderForEachsAsStringInvalue.Split(","c)b…
这个好人
解决方案:
用ASC码会简单很多。
解决方案:
学习,回答问题也长知识。这也是一次锻炼的机会,谢谢
解决方案:
引用35楼tjficcbw的回复:
学习,回答问题也长知识。这也是一次锻炼的机会,谢谢
我当初就象你这样,结果是进步很快.
解决方案:
什么呀