borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (vb6 connect phone)Next Topic (Receiving from XML) New Topic New Poll Post Reply
AndreaVB Forum : Pocket PC : Passing Parameter To Next Form
Poster Message
Winder
Level: Protégé

Registered: 20-04-2006
Posts: 7

icon Passing Parameter To Next Form

Current form has 2 TextField:

Form1:
UserName & Password
How do I Pass the UserName TextField Text to the Next Form.
Which is Form2

Kindly Reply, Thank You for any help given.

20-04-2006 at 05:11 AM
View Profile Send Email to User Show All Posts | Quote Reply
xtramac
Level: Professor


Registered: 28-08-2005
Posts: 89
icon Re: Passing Parameter To Next Form

hello....

you can use public variables...

hope this helps..

andrew

20-04-2006 at 06:58 AM
View Profile Send Email to User Show All Posts | Quote Reply
sanc1
Level: Sage

Registered: 30-09-2003
Posts: 56
icon Re: Passing Parameter To Next Form

Hi Winder,
                There are lot of ways to accomplish ur objective:

1. As xtramac suggested u can use public variables.

2. U can also use global variables, which gets initialised from form1, and u can read those from form2.

3. You can do it through constructor itself.

Lemme give u a small code snippet[C#] to support point 3.

In Form1[anywhere u want to call form2]

form2 myForm2=new form2(string Username);
myForm2.Show();
-------------------------------------------------------
In Form2 [Consructor]

public form2(string DataFromForm1)
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}

So, DataFromForm1 will contain the value u passed from form1.  

Hope it helped else revert back, incase u need more clarification.

____________________________
Bite the bit
sanc1@rediffmail.com

24-04-2006 at 11:42 AM
View Profile Send Email to User Show All Posts | Quote Reply
Winder
Level: Protégé

Registered: 20-04-2006
Posts: 7
icon Re: Passing Parameter To Next Form

form2 myForm2=new form2(string Username);
myForm2.Show();

How to code this in VB ?

This is my VB Code:

Dim sf As Form2
sf = New Form2
sf.Show()
Me.Hide()

25-04-2006 at 05:42 AM
View Profile Send Email to User Show All Posts | Quote Reply
sanc1
Level: Sage

Registered: 30-09-2003
Posts: 56
icon Re: Passing Parameter To Next Form

Hi Winder,
               My previous code snippet was in C#. Here is the equivalent VB.Net code...

Form1
------------------

Public Class Form1

Inherits System.Windows.Forms.Form

Public msgToPass As String

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

msgToPass = "It's fun"

Dim myForm2 As New Form2(msgToPass)
myForm2.Show()

End Sub
End Class


Form2
------------------

Public Class Form2

Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public msgReceived As String
    
    Public Sub New(ByVal msgReceived)
    
    MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call
       MessageBox.Show(msgReceived)
    End Sub

#End Region
End Class


Look, in Form1 and Form2 code, whatever changes I made, is in bold. Hope it's clear to you now, and this is what you are looking for. If not so, hit back again  




____________________________
Bite the bit
sanc1@rediffmail.com

25-04-2006 at 05:03 PM
View Profile Send Email to User Show All Posts | Quote Reply
Winder
Level: Protégé

Registered: 20-04-2006
Posts: 7
icon Re: Passing Parameter To Next Form

sanc1, can you help me on this ? it seems that my buffer size is too small, and i have only receive part of the XML data which i am getting from, so when i returndata, i only get part of it.

Can you help ? Anyone ?

    Public num As Integer = 0
    Public ns As NetworkStream
    Public returndata As String
    Public client As New TcpClient

Public Function receive()
        ns = client.GetStream()
        Dim bytes(client.ReceiveBufferSize.MaxValue) As Byte
        ns.Read(bytes, 0, CInt(client.ReceiveBufferSize))
        returndata = System.Text.Encoding.ASCII.GetString(bytes, 0, bytes.Length)
        Return returndata
End Function

26-04-2006 at 12:39 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : Pocket PC : Passing Parameter To Next Form
Previous Topic (vb6 connect phone)Next Topic (Receiving from XML) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder