I've no idea how you'd do this in phalanger but in C# Windows Forms you could do it as follows.
Note that since array indexing starts at 0 in C# you have to add 1 to get the value of the corresponding character:
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
char[] ar = {'A', 'B', 'C', 'D', 'E'};
public Form1()
{
InitializeComponent();
}
// add this handler by double clicking on form in VS designer
private void Form1_Load(object sender, EventArgs e)
{
string[] items = { "DAB", "BED", "CAD" }; // or whatever
comboBox1.DataSource = items;
}
// add this handler by double clicking on combobox in VS designer
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboBox1.SelectedIndex > -1)
{
textBox1.Text = comboBox1.SelectedItem.ToString();
}
}
// add this handler by double clicking on textbox1 in VS designer
private void textBox1_TextChanged(object sender, EventArgs e)
{
string text = textBox1.Text;
if (text != "")
{
int total = 0;
for (int i = 0; i < text.Length; i++)
{
int index = Array.IndexOf(ar, text[i]); // gets index of letter in array
if (index > -1) total += index + 1;
}
textBox2.Text = total.ToString();
}
}
}
}