Quote Originally Posted by Taem View Post
Here is my the relevant section of my code:

Code:
 If NineInEight = "1" Then
                    If PickIt = "1" Then WebWindow.WebBrowser1.Document.GetElementById("promptInput_41188").SetAttribute("value", PickOne)
                    If PickIt = "2" Then WebWindow.WebBrowser1.Document.GetElementById("promptInput_41188").SetAttribute("value", PickTwo)
                    If PickIt = "3" Then WebWindow.WebBrowser1.Document.GetElementById("promptInput_41188").SetAttribute("value", PickThree)
                    If PickIt = "4" Then WebWindow.WebBrowser1.Document.GetElementById("promptInput_41188").SetAttribute("value", PickFour)
                    If PickIt = "5" Then WebWindow.WebBrowser1.Document.GetElementById("promptInput_41188").SetAttribute("value", PickFive)
                    If PickIt = "6" Then WebWindow.WebBrowser1.Document.GetElementById("promptInput_41188").SetAttribute("value", PickSix)
                    If PickIt = "7" Then WebWindow.WebBrowser1.Document.GetElementById("promptInput_41188").SetAttribute("value", PickSeven)
                    If PickIt = "8" Then WebWindow.WebBrowser1.Document.GetElementById("promptInput_41188").SetAttribute("value", PickEight)
                    If PickIt = "9" Then WebWindow.WebBrowser1.Document.GetElementById("promptInput_41188").SetAttribute("value", PickNine)
                    If PickIt = "10" Then WebWindow.WebBrowser1.Document.GetElementById("promptInput_41188").SetAttribute("value", PickTen)
                    If PickIt = "11" Then WebWindow.WebBrowser1.Document.GetElementById("promptInput_41188").SetAttribute("value", PickEleven)
                    If PickIt = "12" Then WebWindow.WebBrowser1.Document.GetElementById("promptInput_41188").SetAttribute("value", PickTwelve)
                    If PickIt = "13" Then WebWindow.WebBrowser1.Document.GetElementById("promptInput_41188").SetAttribute("value", PickThirteen)

                ElseIf NineInEight = "2" Then

                End If
Basically I just want to shorten it. I'm pretty sure I can use: For i = 1 to 13 / Next and set the If Pickit = i Then.... ("value", Pick......) <- but this is where I'm stumped. Not sure how to proceed to make this simpler on myself using the value "Pick"... Ideas?
vb Code:
  1. Public Class MainForm
  2.  
  3.     Private Sub PickElementValue()
  4.         Dim nineInEight As String = "4" ' Example...
  5.         Dim dic As New Dictionary(Of String, String) From
  6.                                                                   {
  7.                                                                       {"1", "PickOne"},
  8.                                                                       {"2", "PickTwo"},
  9.                                                                       {"3", "PickThree"},
  10.                                                                       {"4", "PickFour"},
  11.                                                                       {"5", "PickFive"}
  12.                                                                   }
  13.  
  14.         Dim picked = (From d In dic Where d.Key = nineInEight Select d.Value).FirstOrDefault
  15.         Me.WebBrowser1.Document.GetElementById("promptInput_41188").SetAttribute("value", picked)
  16.     End Sub
  17. End Class