0

我有一个将值显示为 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) 中为此编写代码

4

1 回答 1

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;
    }
 }

在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
于 2013-04-30T10:57:44.187 回答