Help with a problem with 2 forms!!!

--DANNY--

Member
Joined
Dec 8, 2004
Messages
10
Location
Washington
Programming Experience
1-3
I have 2 forms. frmBrowser and frmFTP. I have a web browser window thing in frmBrowser, and a string called strFTPAddress which is whatever is entered into a textbox on that form, and a button on each form. I want to be able to press a button on frmBrowser to open up frmFTP. Then enter a site into the textbox, which saves it to strFTPAddress. Then press a button on frmFTP that makes the browser box in frmBrowser goto the site in the string.

So far, I have it setup so that when you press a button on frmBrowser, frmFTP opens up. Then when you enter something for the string, and press the button, nothing happens on the frmBrowser page.

How do I make this work?

This is what I have for the button on frmFTP...


PrivateSub btnLogin_Click(ByVal sender As System.Object, ByVal e As ystem.EventArgs) Handles btnLogin.Click
Dim main As frmBrowser
Dim strFTPAddress AsString
strFTPAddress = txtFTPAddress.Text
main.awbWindow.Navigate(strFTPAddress)
me.close()
EndSub



THIS IS WHAT I GET WHEN I CLICK ON THE BUTTON ON FrmFTP




 

--DANNY--

Member
Joined
Dec 8, 2004
Messages
10
Location
Washington
Programming Experience
1-3
Now I don't get an exeption error, but It doesn't do anything...
Here's specifically what I put for the 2 forms...

frmBrowser
PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As ystem.EventArgs) Handles btnFTP.Click

Dim FTP AsNew frmFTP
FTP.Owner = Me
FTP.Show()
EndSub
frmFTP
PrivateSub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click

Dim strFTPAddress AsString
strFTPAddress = txtAddress.text

Dim main AsNew frmBrowser
main.awbWindow.Navigate(strFTPAddress)
EndSub
If anyone can help me, I would be HIGHLY appreciative.
Thanx!

If you have AIM, then please IM me at 'AahSnaps'
 

Paszt

Staff member
Joined
Jun 3, 2004
Messages
1,500
Location
Raleigh, NC - USA
Programming Experience
Beginner
Did you not understand the article or was it not what you're looking for?

If you make a module and declare both forms:
VB.NET:
Module Module1

    Friend fMain As frmBrowser
    Friend fFTP As frmFTP

    <STAThread()> _
    Public Sub Main()
        Dim frm As New frmBrowser()
        frm.show()
    End Sub

End Module
Be sure to set the Startup Object to 'Sub Main'.

Then in frmBrowser's load event handler set frmBrowser = Me.
Open frmFTP, type something in the textbox and use this code in the button's click event handler:
VB.NET:
Private Sub btnLogin_Click(ByVal sender As System.Object, _
  ByVal e As System.EventArgs) Handles btnLogin.Click
    fMain.awbWindow.Navigate(txtAddress.Text)
End Sub
 

tonmoy

Member
Joined
Dec 2, 2004
Messages
6
Programming Experience
1-3
Hi Danny!

You follow the steps as below..

1. Form1 contains an AxBrowser control(named MyBrow) and a button(cmdGo)
2. Form2 contains a textbox(Txt1) and a button(Show)

Form1.vb

Private Sub cmdGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdGo.Click
Dim FTP As New Form2(Me)

FTP.ShowDialog(
Me)

FTP.Dispose()

FTP =
Nothing

End Sub

Form2.vb
Public Class Form2

Inherits System.Windows.Forms.Form

Dim frm As New Form1

Private Sub Show_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Show.Click

frm.MyBrow.Navigate(
Me.Txt1.Text)

End Sub

End Class

After This Open the Region section of form2 and add the following code just after Public Sub New()...End Sub.

Public Sub New(ByVal frm As Form1)

MyBase.New()

InitializeComponent()

Me.frm = frm

End Sub

Thanks
Tonmoy
 

--DANNY--

Member
Joined
Dec 8, 2004
Messages
10
Location
Washington
Programming Experience
1-3
Wow...I am VERY confused. I tried both of those, and it still wouldn't work.
Now I just have a giant jumble of code.

I would REALLY appreciate it if someone would take a look at this project, and try to fix things.

http://home.comcast.net/~dsdahl89/files/Browser.rar
If you don't have a tool to extract rar files then use this.
http://home.comcast.net/~dsdahl89/files/Browser.zip

To be more specific. Once you have it opened, note that I want the "FTP" button on the frm browser to open up the frmFTP. Then the "Login" button on frmFTP to navigate the browser on frmBrowser to the string of strFTPAddress. Then close the frmFTP window.

PLEASE take a look at this if you have time!

If you don't have a way to temporarily upload the project if/when you fix it, then please send it as an attachment to DSDahl89@comcast.net.

Thanks ALOT!
 

JuggaloBrotha

VB.NET Forum Moderator
Staff member
Joined
Jun 3, 2004
Messages
4,524
Location
Lansing, MI; USA
Programming Experience
10+
i'll peep it tonight (although someone else here will most likely beat me to it, which is cool too)
 

TPM

Well-known member
Joined
Dec 7, 2004
Messages
623
Location
CA
Programming Experience
3-5
Well you still need a New in your frmbrowser when diming frmftp.
Running events between forms can be a pain, what I'd do would be make a shared public string in your formbrowser then use frmftp.showdialog (not .show), set the shared string to the url in your frmftp. Then after the frm.showdialog check the value/navigate of the shared string.

Hope that helps
TPM
 

Paszt

Staff member
Joined
Jun 3, 2004
Messages
1,500
Location
Raleigh, NC - USA
Programming Experience
Beginner
All the suggestions that myself, TPM, and tonmoy have given are valid.
I looked at your project and you didn't incorporate any of the suggestions.
If you have specific questions regarding how to implement any of the suggestions, let us know :).
 

--DANNY--

Member
Joined
Dec 8, 2004
Messages
10
Location
Washington
Programming Experience
1-3
Ok, but I have tried the other ways mentioned. But the project that I uploaded is from before I had tried any of it. Because I figured since it didn't work for me, then why include it.
 

JuggaloBrotha

VB.NET Forum Moderator
Staff member
Joined
Jun 3, 2004
Messages
4,524
Location
Lansing, MI; USA
Programming Experience
10+
i got your project to work with the sugestions posted here, i'll upload it sometime tonight so you can see for yourself also the actual code you have for logging into the ftp site you specified doesnt work either (fyi)
 

JuggaloBrotha

VB.NET Forum Moderator
Staff member
Joined
Jun 3, 2004
Messages
4,524
Location
Lansing, MI; USA
Programming Experience
10+
unzip all the files, then simply double click browser.sln (this is the main solution file that tells vb to load the other files) and your good ta go
 
Top Bottom