yet another newbie question!

newbie82

Member
Joined
Mar 7, 2005
Messages
9
Programming Experience
Beginner
question on strings and forms

Hello,
I have a textbox on 'form4' in which a web address is typed with an 'ok' button under it. When 'ok' is clicked the address is stored as a string:

Dim strHomepage As String
strHomepage = txthomepage.text

On 'form1' there is a button which, when clicked, I would like to navigate the axwebbrowser(also on 'form1') to strHomepage.
I have delcared 'strHomepage' as being public and have the following code in the click event of the button on 'form1':
AxWebBrowser.Navigate(strHomepage)
I get no errors but it does not work. Been staring at this for so long that I'm probably missing something obvious.
Any help greatly appreciated!!
 
Last edited:

newbie82

Member
Joined
Mar 7, 2005
Messages
9
Programming Experience
Beginner
having had another look at it, i think its something to do with not being able to declare a public variable in an event procedure (the 'ok' button click event)how do i make the string that is initialised in an event procedure visible to the other forms???
 

eagle

Active member
Joined
Mar 8, 2005
Messages
28
Programming Experience
1-3
Is your strHomepage correct? If i understand it correct, you want to give strHomepage a value in Form4 and then use it in Form1 right?
Then you just have to put your strHomepage public shared in your Form1 so,
Public Shared strHomepage As String

When you want to set a value then in form4, you just have to do
Form1.strHomepage = TextBox1.Text

and normally it should work in your Form1.

I hope this solves your problem.

 

JuggaloBrotha

VB.NET Forum Moderator
Staff member
Joined
Jun 3, 2004
Messages
4,524
Location
Lansing, MI; USA
Programming Experience
10+
i'd add a module to the project and in the module declare a homepage variable:

Friend gstrHomePage as String

that string is public to all the forms in the solution
 
Top Bottom