Results 1 to 6 of 6

Thread: new window

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2004
    Posts
    13

    new window

    can somebody please tell me what code i have to write to make a new window appear.

  2. #2
    Hyperactive Member Blacknight's Avatar
    Join Date
    Nov 2002
    Posts
    381
    to make a new form appear:
    VB Code:
    1. form2.show

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2004
    Posts
    13
    ok but i want to make form 1 edited by form 2

    ex: i want to be able to type a vlue in to a text field(in for 2) and press ok and the the label in text one will show the value...for example form 2 will ask what is your name and i will type Anuj and click ok and then a label will apear in form 1 saying hello anuj,
    Last edited by A_A_68; Oct 26th, 2004 at 03:46 PM.

  4. #4
    so type a value into Text1 and then have it displayed onto form2 as a caption?


    Form1

    VB Code:
    1. Option Explicit
    2.  
    3. Public pName As String
    4.  
    5. Private Sub Command1_Click()
    6.  
    7. pName = Text1.Text
    8. Me.Hide
    9. Form2.Show
    10. End Sub

    Form2

    VB Code:
    1. Private Sub Form_Load()
    2.  
    3. Label1.Caption = "Hello '" & Form1.pName & "'"
    4.  
    5. End Sub

    that what u wanted?

  5. #5

    Thread Starter
    New Member
    Join Date
    Oct 2004
    Posts
    13
    thanks alot man
    Last edited by A_A_68; Oct 28th, 2004 at 07:20 PM.

  6. #6
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632
    Hmmm if you want to do it properly then do:
    In form 2 do:
    VB Code:
    1. Option Explicit
    2.  
    3. Private mstrUsername As String
    4.  
    5. Public Property Let Username(ByVal Value As String)
    6.    mstrUsername = Value
    7. End Property
    8.  
    9. Private Sub Form_Load()
    10.    lblUsername.Caption = "Hello " & mstrUsername
    11. End Sub
    Then in form 1 do:
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Command1_Click()
    4. Dim frmNew As Form2
    5.    Set frmNew = New Form2
    6.    frmNew.Username = Text1.Text
    7.    Load frmNew
    8.    frmNew.Show
    9.    Set frmNew = Nothing
    10. End Sub
    Much much neater coding. There is never any need for public varibles in a form.

    Woka

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width