我有一个文本框,显示值为10,20,30,即
textbox1.text="10,20,30,50"
预定义值:10-A, 20-B, 30-$, 50-*
我希望label1
中显示的值符合textbox1
值,因此现在根据此textbox1
值
Label1.text="AB$*"
我想在Vb.net(asp.net)中编写代码
答案 0 :(得分:0)
在c#
中string textboxval=textbox1.text;
string[] words = textboxval.Split(',');
foreach (string word in words)
{
int no=int.parse(word);
switch(no)
{
case 10:
label1.text += "A";
break;
case 20:
label1.text += "B";
break;
case 30:
label1.text += "$";
break;
case 50:
label1.text += "*";
break;
}
}
in vb
Dim textboxval As String = textbox1.text
Dim words As String() = textboxval.Split(","C)
For Each word As String In words
Dim no As Integer = Integer.parse(word)
Select Case no
Case 10
label1.text += "A"
Exit Select
Case 20
label1.text += "B"
Exit Select
Case 30
label1.text += "$"
Exit Select
Case 50
label1.text += "*"
Exit Select
End Select
Next