EDN Admin
Well-known member
I am using Visual Basic 2010 to automate a custom web page for data entry. The data is currently entered using a hand held scanner. The scanner scans a barcode and the page is updated.<span>
To improve error proofing I was asked to automatically input this data from a PLC controller. Everything is great until I hit the web page. I insert the data and I call for the button to be clicked as I have in other places and it will not function.
If I click the button on the page it works, if I click on a button on the form it works, and if I click off the page it works. I know it’s a little something I’m missing, but Im stumped.
<span style="text-decoration:underline The buttons I’m automating:
<input type="submit" name="btnExit" value="Exit" id="btnExit" />
<span>
<input type="submit" name="btnReplenish" value="Replenish" id="btnReplenish" />
<span>
<input type="submit" name="btnNext" value="Next" onclick="fnClickOnce(this,btnNext);WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("btnNext", "", true, "", "", false,
false))" id="btnNext" /><span>
<span>
<span style="text-decoration:underline The VB code I’m working with:
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; color:blue; font-size:9.5pt Dim<span style="font-family:Courier New; font-size:9.5pt FCCSN
<span style="color:blue As <span style="color:#2b91af HtmlElement = WebBrowser1.Document.GetElementById(<span style="color:#a31515 "txtLabel")
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; color:blue; font-size:9.5pt Dim<span style="font-family:Courier New; font-size:9.5pt NButton
<span style="color:blue As <span style="color:#2b91af HtmlElement = WebBrowser1.Document.GetElementById(<span style="color:#a31515 "btnNext")
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; color:blue; font-size:9.5pt Dim<span style="font-family:Courier New; font-size:9.5pt EButton
<span style="color:blue As <span style="color:#2b91af HtmlElement = WebBrowser1.Document.GetElementById(<span style="color:#a31515 "btnExit")
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; color:blue; font-size:9.5pt Dim<span style="font-family:Courier New; font-size:9.5pt SearchText
<span style="color:blue As <span style="color:blue String
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; color:blue; font-size:9.5pt Dim<span style="font-family:Courier New; font-size:9.5pt PageText
<span style="color:blue As <span style="color:blue String
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; color:blue; font-size:9.5pt Dim<span style="font-family:Courier New; font-size:9.5pt PageCSN
<span style="color:blue As <span style="color:blue String
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; color:blue; font-size:9.5pt Dim<span style="font-family:Courier New; font-size:9.5pt PartNumber
<span style="color:blue As <span style="color:blue String
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; color:blue; font-size:9.5pt Dim<span style="font-family:Courier New; font-size:9.5pt x
<span style="color:blue As <span style="color:blue Double
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; font-size:9.5pt FloorConsolePageUpandRunning =
<span style="color:blue True
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; color:blue; font-size:9.5pt If<span style="font-family:Courier New; font-size:9.5pt FloorConsolePageUpandRunning =
<span style="color:blue True <span style="color:blue Then
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; font-size:9.5pt <span>
SearchText = <span style="color:#a31515 "CSN:"
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; font-size:9.5pt <span>
PageText = WebBrowser1.Document.Body.InnerText
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; font-size:9.5pt <span>
<span style="color:blue If InStr(PageText, SearchText) > 0 <span style="color:blue
Then
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; font-size:9.5pt <span>
<span style="color:green ++++++++++++++++++++++Get CSN on Page and save it+++++++++++++
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; font-size:9.5pt <span>
<span> PageCSN = GetCSNonPage()
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; font-size:9.5pt <span>
<span> <span style="color:blue If PageCSN <>
<span style="color:#a31515 "NULL" <span style="color:blue Then
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; font-size:9.5pt <span>
<span> TA_CurrentCSN.UpdateCSN(PageCSN)
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; font-size:9.5pt <span>
x = <span style="color:blue CType(PageCSN, <span style="color:blue
Double)
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; font-size:9.5pt <span>
<span style="color:blue If x > 0 <span style="color:blue Then
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; font-size:9.5pt <span>
<span> Label12.Text = PageCSN
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; font-size:9.5pt <span>
PartNumber = GetPartNumber(PageCSN)
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; font-size:9.5pt <span>
TextBox1.Text = PartNumber
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; font-size:9.5pt <span>
Button1Stuff()<span>
<span style="font-family:Wingdings; font-size:9.5pt <span>ß<span style="font-family:Courier New; font-size:9.5pt Conditions the data for entry<span style="font-family:Courier New; font-size:9.5pt <span> <span>
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; font-size:9.5pt <span> NButton.InvokeMember(<span style="color:#a31515 "click")<span> <span style="font-family:Wingdings; font-size:9.5pt <span>ß<span style="font-family:Courier New; font-size:9.5pt The
button that wouldn’t click
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; font-size:9.5pt <span>
<span style="color:blue End <span style="color:blue If
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; font-size:9.5pt <span>
<span style="color:blue End <span style="color:blue If
View the full article
To improve error proofing I was asked to automatically input this data from a PLC controller. Everything is great until I hit the web page. I insert the data and I call for the button to be clicked as I have in other places and it will not function.
If I click the button on the page it works, if I click on a button on the form it works, and if I click off the page it works. I know it’s a little something I’m missing, but Im stumped.
<span style="text-decoration:underline The buttons I’m automating:
<input type="submit" name="btnExit" value="Exit" id="btnExit" />
<span>
<input type="submit" name="btnReplenish" value="Replenish" id="btnReplenish" />
<span>
<input type="submit" name="btnNext" value="Next" onclick="fnClickOnce(this,btnNext);WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("btnNext", "", true, "", "", false,
false))" id="btnNext" /><span>
<span>
<span style="text-decoration:underline The VB code I’m working with:
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; color:blue; font-size:9.5pt Dim<span style="font-family:Courier New; font-size:9.5pt FCCSN
<span style="color:blue As <span style="color:#2b91af HtmlElement = WebBrowser1.Document.GetElementById(<span style="color:#a31515 "txtLabel")
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; color:blue; font-size:9.5pt Dim<span style="font-family:Courier New; font-size:9.5pt NButton
<span style="color:blue As <span style="color:#2b91af HtmlElement = WebBrowser1.Document.GetElementById(<span style="color:#a31515 "btnNext")
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; color:blue; font-size:9.5pt Dim<span style="font-family:Courier New; font-size:9.5pt EButton
<span style="color:blue As <span style="color:#2b91af HtmlElement = WebBrowser1.Document.GetElementById(<span style="color:#a31515 "btnExit")
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; color:blue; font-size:9.5pt Dim<span style="font-family:Courier New; font-size:9.5pt SearchText
<span style="color:blue As <span style="color:blue String
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; color:blue; font-size:9.5pt Dim<span style="font-family:Courier New; font-size:9.5pt PageText
<span style="color:blue As <span style="color:blue String
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; color:blue; font-size:9.5pt Dim<span style="font-family:Courier New; font-size:9.5pt PageCSN
<span style="color:blue As <span style="color:blue String
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; color:blue; font-size:9.5pt Dim<span style="font-family:Courier New; font-size:9.5pt PartNumber
<span style="color:blue As <span style="color:blue String
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; color:blue; font-size:9.5pt Dim<span style="font-family:Courier New; font-size:9.5pt x
<span style="color:blue As <span style="color:blue Double
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; font-size:9.5pt FloorConsolePageUpandRunning =
<span style="color:blue True
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; color:blue; font-size:9.5pt If<span style="font-family:Courier New; font-size:9.5pt FloorConsolePageUpandRunning =
<span style="color:blue True <span style="color:blue Then
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; font-size:9.5pt <span>
SearchText = <span style="color:#a31515 "CSN:"
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; font-size:9.5pt <span>
PageText = WebBrowser1.Document.Body.InnerText
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; font-size:9.5pt <span>
<span style="color:blue If InStr(PageText, SearchText) > 0 <span style="color:blue
Then
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; font-size:9.5pt <span>
<span style="color:green ++++++++++++++++++++++Get CSN on Page and save it+++++++++++++
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; font-size:9.5pt <span>
<span> PageCSN = GetCSNonPage()
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; font-size:9.5pt <span>
<span> <span style="color:blue If PageCSN <>
<span style="color:#a31515 "NULL" <span style="color:blue Then
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; font-size:9.5pt <span>
<span> TA_CurrentCSN.UpdateCSN(PageCSN)
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; font-size:9.5pt <span>
x = <span style="color:blue CType(PageCSN, <span style="color:blue
Double)
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; font-size:9.5pt <span>
<span style="color:blue If x > 0 <span style="color:blue Then
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; font-size:9.5pt <span>
<span> Label12.Text = PageCSN
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; font-size:9.5pt <span>
PartNumber = GetPartNumber(PageCSN)
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; font-size:9.5pt <span>
TextBox1.Text = PartNumber
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; font-size:9.5pt <span>
Button1Stuff()<span>
<span style="font-family:Wingdings; font-size:9.5pt <span>ß<span style="font-family:Courier New; font-size:9.5pt Conditions the data for entry<span style="font-family:Courier New; font-size:9.5pt <span> <span>
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; font-size:9.5pt <span> NButton.InvokeMember(<span style="color:#a31515 "click")<span> <span style="font-family:Wingdings; font-size:9.5pt <span>ß<span style="font-family:Courier New; font-size:9.5pt The
button that wouldn’t click
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; font-size:9.5pt <span>
<span style="color:blue End <span style="color:blue If
<p style="line-height:normal; margin-bottom:0pt <span style="font-family:Courier New; font-size:9.5pt <span>
<span style="color:blue End <span style="color:blue If
View the full article