Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / February 2006

Tip: Looking for answers? Try searching our database.

Write Variable value to Text box using VB.net

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JerryB - 31 Jan 2006 22:26 GMT
Sorry I am new with infopath. I am just trying to write a variable to a
textbox on my form. and dont know where to start.

Form name = Project_Approval
Field name= Approver_name

can anyone help.

Thank you.
Sandeep - 01 Feb 2006 07:20 GMT
Hi JerryB

This is Xpath of text box "/my:myFields/my:field1"
.....
Drag the button in task pane controls and double click on button and click
on "edit with form code".
Now past this code.

Dim myField
myField = "I am new with infopath"
XDocument.DOM.selectSingleNode("/my:myFields/my:field1").text()=myField

I hope this will help U.
Signature

Sandeep
www.autonomysystems.com

Jerry - 01 Feb 2006 15:45 GMT
Thank you for the help. I am sure I am still doing something wrong.

If I copy the statement in as written I get an error on XDocument.dom that
says "Reference to non-shared member requires an object reference.

And I am nit sure what my xpath should say. The form name is
Project_Approvals and the Field name is Approver_name so should it be. /my:
Project_Approvals/my:Approver_Name

Thank you for the help. I really appreciate it.
Here is all the code.

 Public Sub _Startup(ByVal app As Application, ByVal doc As XDocument)
           thisXDocument = doc
           thisApplication = app
           ' You can add additional initialization code here.
       End Sub

<InfoPathEventHandler(MatchPath:="CTRL4_7", EventType:=InfoPathEventType.
OnClick)> _
       Public Sub CTRL4_7_OnClick(ByVal e As DocActionEvent)
           ' Write your code here.
           Dim myField
           myField = "I am new with infopath"
           XDocument.DOM.selectSingleNode("/my:myFields/my:Approver_Name").
text() = myField
       End Sub

>Hi JerryB
>
[quoted text clipped - 9 lines]
>
>I hope this will help U.
Sandeep - 01 Feb 2006 17:00 GMT
Hi JerryB
sorry, i written this code in VBscript .--
Not VB.NET
InfoPath form:
Just go to "Tools" menu and select "advenced" option and change "form code
language" to VBscript

Sandeep
www.autonomysystems.com

> Thank you for the help. I am sure I am still doing something wrong.
>
[quoted text clipped - 37 lines]
> >
> >I hope this will help U.
Jerry - 01 Feb 2006 17:55 GMT
I cant change the forms type of code. It says managed Code and it is greyed
out. I tried starting a new form and put the code in that form and still get
an error.  If I change to VBscript I cant pull the username. Do you know how
to do this in VB.net.

>Hi JerryB
>sorry, i written this code in VBscript .--
[quoted text clipped - 11 lines]
>> >
>> >I hope this will help U.
Sandeep - 02 Feb 2006 07:00 GMT
Hi JerryB

This is VB.net code.

Dim node As IXMLDOMNode
           node =
thisXDocument.DOM.selectSingleNode("/my:myFields/my:field1")
           node.text = "HI"

I hope this will help U
Signature

Sandeep
www.autonomysystems.com

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.