Need help trying to call from a .txt file after compilation.

simpleonline

Active member
Joined
Sep 13, 2011
Messages
33
Programming Experience
Beginner
Hey guys,

It's me Mr. Confusing again.

I am trying to add this code (call this code) from a .txt file on my computer after run time.

Before compilation I can add this code to my form and it runs great by manually placing the webbrowser.navigate & addhandlers under a button and the rest by itself, but I am wanting to add this code after my app is compiled using by clicking a button.

My thought process on this was to have the code done in a .txt like I have and then before compiliation go into the btn1 on my form and code it to say whatever .txt I open using the openfiledialog pull the code into the form and use it.

I know that manually just placing the webbrowser.navigate and the addhandlers under the button manually (and adding the hanlders and public new instance of the form) will do the trick but there has to be a better way of going about this seeing that I am going to have about 500 .txt files to draw from.

I was thinking of maybe looping through a folder and grabbing each .txt in the folder and calling them into the form by doing something??? but I'm lost at this step.

Any ideas on how to go about this?

Thanks

Here is the code from one of the .txt files.
VB.NET:
'Connotea DECLARATION
Public Connotea as new captchawindow
 
Public Sub ConnoteaNavigate
Connotea.webbrowser1.navigate("http://www.connotea.org/register")
End Sub
 
Public Sub ConnoteaHandlers
 
AddHandler Connotea.button1.click, addressof Connoteabutton
AddHandler Connotea.webbrowser1.documentcompleted, addressof Connoteabrowsercompleted
End Sub
 
Public Sub Connoteabrowsercompleted
 
For Each element as HtmlElement in Connotea.WebBrowser1.Document.Getelementsbytagname("input")
If element.getattribute("id") = "firstname" then
element.setAttribute("value", ProfileMaker.FirstName.Text)
End If
Next
 
For Each element as HtmlElement in Connotea.WebBrowser1.Document.Getelementsbytagname("input")
If element.getattribute("id") = "lastname" then
element.setAttribute("value", ProfileMaker.LastName.Text)
End If
Next
 
For Each element as HtmlElement in Connotea.WebBrowser1.Document.Getelementsbytagname("input")
If element.getattribute("id") = "username" then
element.setAttribute("value", ProfileMaker.Username.Text)
End If
Next
 
For Each element as HtmlElement in Connotea.WebBrowser1.Document.Getelementsbytagname("input")
If element.getattribute("id") = "password" then
element.setAttribute("value", ProfileMaker.Password.Text)
End If
Next
 
For Each element as HtmlElement in Connotea.WebBrowser1.Document.Getelementsbytagname("input")
If element.getattribute("id") = "passwordconfirm" then
element.setAttribute("value", ProfileMaker.Password.Text)
End If
Next
 
For Each element as HtmlElement in Connotea.WebBrowser1.Document.Getelementsbytagname("input")
If element.getattribute("id") = "email" then
element.setAttribute("value", ProfileMaker.Email.Text)
End If
Next
 
For Each element as HtmlElement in Connotea.WebBrowser1.Document.Getelementsbytagname("input")
If element.getattribute("id") = "email2" then
element.setAttribute("value", ProfileMaker.Email.Text)
End If
Next
 
If Connotea.WebBrowser1.ReadyState = WebBrowserReadyState.Complete Then
For Each Captcha As HtmlElement In Connotea.WebBrowser1.Document.Images
If Captcha.GetAttribute("src").Contains("http://www.google.com/recaptcha/api/image?c=") Then
Connotea.PictureBox1.Load(Captcha.GetAttribute("src"))
End If
Next
End If
 
 
End Sub
 
Public Sub Connoteabutton
 
Connotea.show
 
For Each element as HtmlElement in Connotea.WebBrowser1.Document.Getelementsbytagname("input")
If element.getattribute("id") = "recaptcha_response_field" then
element.setAttribute("value", Connotea.Textbox1.Text)
End If
Next
 
For Each element as HtmlElement in Connotea.WebBrowser1.Document.Getelementsbytagname("input")
If element.getattribute("value") ="register" then
 element.InvokeMember("click")
End If
Next
 
Connotea.dispose
End Sub
 
You cannot compile and execute code stored in a text file at run time. What you can do is store a list of custom commands in a text file, and interpret these commands with your own interpreter.
 
Back
Top