Click here to Skip to main content
15,897,273 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Look Guys ..
To make my problem clear
I have two forms..
Form 1: 1 textbox and 1 button ( button don't show the name that user enter in txtbox but open form 2)
Form 2: 1 txtbox and button, (in txtbox form 1 user enter name) in this txtbox form 2 the user enter his lastname...The button will show a msgbox wich show up the name and lastname..


how can i do it?


I tried like thi: but it doesn't work out :/

VB
Private Sub Command1_Click()
Static name As Integer
Static lastname As Integer
firstname = txtFirstName.Text
LastName = txtLastName.Text
txtFirstName.Text = Form1.txtFirstName.Text
txtLastName.Text = Form2.txtLastName.Text

both = (Form1.txtFirstName.Text " & & " Form2.txtLastName.Text)
MsgBox (both)

End Sub
Posted
Updated 30-Dec-12 4:27am
v3
Comments
CHill60 30-Dec-12 10:31am    
What doesn't work out? What error message or results do you get?
San Dra 30-Dec-12 10:58am    
It doesn't display anything..nothing from form 1 only form 2
San Dra 30-Dec-12 10:59am    
this code is on command button form 2...while the textboxes in form 1 can't be displayed in form 2
CHill60 30-Dec-12 19:13pm    
I'm not surprised this doesn't display anything - it won't even compile ...
Firstly - if this code is on a button on form2 you can't refer to it as Form2.txtLastName.Text - use "Me" instead.
Next - "Static lastname As Integer" then you try to assign txtLastName.Text to it??
why declare "name" as integer or at all
Where is "firstname" declared?
There's more to deal with but get started on fixing the problems I've listed and try again
San Dra 31-Dec-12 7:02am    
I don't even know where to declare them, so they can be recognized by all the forms..should I declare them in each form?

Applicable for VB.Net, Not applicable For Classic VB...
VB
Public Class Form2
    Public FirstName As String
    Private Sub Command1_Click() Handles Command1.Click
        Dim LastName As String
        Dim Both As String
        LastName = txtLastName.Text  'Replace txtLastName with Name of Your TextBox

        both = (FirstName & LastName)
        MsgBox (Both)
End Sub
End Class


In Form1 Write code as Follows
VB
Public Class Form1
    Private Sub Command1_Click() Handles Command1.Click
        Form2.FirstName = txtFirstName.Text  'Replace txtFirstName with Name of Your TextBox
        Form2.Show()
        Me.Close
End Sub
End Class
 
Share this answer
 
Hi,

You can hold the value in a variable global type then on second page in messagebox format you can call the the last name value then global value or whatever format you want.

hope it ll help you.

Thanks.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900