0

i have an array of string like this :

A
B
C
D
E
F

i know how to get the index of one letter in the array string like this

Dim itemindex As String = Array.IndexOf(myarr, "C")
TextBox2.Text = itemindex

It return for me the number 2

but i want to know how to do it in the Reverse way like if i give the index 2 i want it to return for me the letter C ?

i want to do that for tow array withe the same size one in the listbox if i select one item i want it to return for me the item in the second array that have the same index number

3
  • 1
    i give the index 2 i want it to return for me the letter C would be: Dim find = myArr(2) common ordinary array reference by index. No idea how the length from the title comes into play Commented Mar 11, 2016 at 21:32
  • @Plutonix Dim charc As String = ListBox2.SelectedItem Select Case charc ` Case charc` charc = myarr(ListBox1.SelectedIndex) End Select TextBox1.Text = charc work for me thank you so match !!!! Commented Mar 11, 2016 at 21:40
  • 1
    it looks like listbox.selectedindex would work and without the implicit data type conversion Commented Mar 11, 2016 at 21:42

1 Answer 1

1

Just use myArr(2) to access the 3rd element in the array.

Or to get a character from a string, use SubString e.g.

s.Substring(startIndex, length)

Length for you would be 1, if you're looking for a single character.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.