我在用户输入一些文本的表单上有一个文本框。每个字母被分配一个不同的值,如 a = 1、b = 2、c = 3 等等。例如,如果用户键入“aa bb ccc”,则标签上的输出应如下所示:
aa = 2
bb = 4
dd = 6
Total value is (12)
我能够通过循环遍历文本框字符串来获得总值,但是如何显示每个单词的总值。这是我到目前为止所拥有的:
For letter_counter = 1 To word_length
letter = Mid(txtBox1.Text, letter_counter, 1)
If letter.ToUpper = "A" Then
letter_value = 1
End If
If letter.ToUpper = "B" Then
letter_value = 2
End If
If letter.ToUpper = "C" Then
letter_value = 3
End If
If letter.ToUpper = "D" Then
letter_value = 4
End If
If letter.ToUpper = "E" Then
letter_value = 5
End If
If letter.ToUpper = " " Then
letter_value = 0
End If
totalletter = totalletter + letter_value
Label1.Text = Label1.Text & letter_value & " "
txtBox2.Text = txtBox2.Text & letter_value & " "
Next letter_counter