shep123:I am trying to write a string of code with vbs which will extract the value from a text box. I will ultimately run an if-then statement with that value (don't think this actually matters but thought I'd put it in here). However, I am having trouble getting the code to actually reference the text box value. I attached the code below if anyone has any ideas. The trxCount text box is an equation that acts as a counter for the number of instances, thus it is an integer if that matters. Any help is appreciated.
Dim fieldValue
Set fieldValue = XDocument.DOM.selectSingleNode("/my:myFields/my:productSelectionSection/my:productSelectionGroup/my:countGroup/my:trxCount)
This should be really easy if to formulate and do WHAT you want instead of HOW
So, I've done it in Visual Basic or VB.NET 2.0 aka 2005, not sure why you gone fancy with VBS
Created an Infopath 2010 client (Filler) form, place there TextBox and, in order to check the code. a button
In "Form Options" (in backstage, having pressed File on ribbon) --> Security and Trust --> I changed Security Level from Domain to Full Trust
Having chosen a textbox, on ribbon clicked Developer and then Changed Event button
This quite helpfully answered you question by inserting into opened in VSTA InternalStartup() method the line:
- AddHandler EventManager.XmlEvents("/my:myFields/my:field1").Changed, AddressOf field1_Changed
I declared your fieldValue outside of methods
In generated
- Public Sub field1_Changed(ByVal sender As Object, ByVal e As XmlEventArgs)
I inserted (or rather chosen from Intellisense pop-up upon entering dot after parameter e)
That's it
Double-checking it
In generated from pressing in Infopath Designer 2010 "Edit Form Code..." button in form's button properties method
- Public Sub CTRL2_5_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)
I inserted
- MessageBox.Show(fieldValue)
For me it worked like a charm, though I do not even know VB.NET, I am a C#/ASP.NET guy!