|
-
May 15th, 2013, 03:56 AM
#10
Re: Looking for an easier way to nestle multiple If statements
 Originally Posted by Taem
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:
Public Class MainForm Private Sub PickElementValue() Dim nineInEight As String = "4" ' Example... Dim dic As New Dictionary(Of String, String) From { {"1", "PickOne"}, {"2", "PickTwo"}, {"3", "PickThree"}, {"4", "PickFour"}, {"5", "PickFive"} } Dim picked = (From d In dic Where d.Key = nineInEight Select d.Value).FirstOrDefault Me.WebBrowser1.Document.GetElementById("promptInput_41188").SetAttribute("value", picked) End Sub End Class
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|