Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB VisualStudio2012
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 :/
 
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 30-Dec-12 5:18am
San Dra391
Edited 30-Dec-12 5:27am
v3
Comments
CHill60 at 30-Dec-12 10:31am
   
What doesn't work out? What error message or results do you get?
San Dra at 30-Dec-12 10:58am
   
It doesn't display anything..nothing from form 1 only form 2
San Dra at 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 at 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 at 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?
San Dra at 31-Dec-12 7:07am
   
All wrong..sorry guys, I've to try all over again
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Applicable for VB.Net, Not applicable For Classic 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
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
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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.
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 269
1 OriginalGriff 240
2 CPallini 195
3 Maciej Los 177
4 BillWoodruff 173
0 OriginalGriff 5,655
1 DamithSL 4,506
2 Maciej Los 3,997
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,180


Advertise | Privacy | Mobile
Web01 | 2.8.141216.1 | Last Updated 3 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100