Info Between Forms

Discussion in 'Archives' started by Jukka, Jun 11, 2007.

Info Between Forms
  1. Unread #1 - Jun 11, 2007 at 3:10 PM
  2. Jukka
    Joined:
    Nov 23, 2005
    Posts:
    244
    Referrals:
    0
    Sythe Gold:
    0

    Jukka Active Member

    Info Between Forms

    Lets say if i have: "Dim FileLocation as String" in Form3.
    and i would like to send that variable to Form1?
    edit: Solved...


    Another problem:
    If i have a Text1.Text in form1 and i would like to give it a variable that form3 has.
    Using the command in form3

    if that makes any sence

    edit3 heres some code:

    Code:
    Private Sub Command2_Click()
      FileLocation = Text1.Text
      Open FileLocation For Input As #1
      Print #1, ScarCode
      Close #1
    End Sub
    
    thats in form3 now i want to send the "ScarCode" variable to ScarCodeText.Text
     
  3. Unread #2 - Jun 11, 2007 at 3:32 PM
  4. timk777
    Joined:
    Feb 19, 2007
    Posts:
    156
    Referrals:
    0
    Sythe Gold:
    0

    timk777 Active Member

    Info Between Forms

    Declare it in a module,

    Public FileLocation as string
     
  5. Unread #3 - Jun 11, 2007 at 3:42 PM
  6. speljohan
    Joined:
    Apr 24, 2005
    Posts:
    1,450
    Referrals:
    3
    Sythe Gold:
    0

    speljohan Guru
    Visual Basic Programmers

    Info Between Forms

    if this was in vb.net it could easily be achieved by adding a constructor for Form1.
     
  7. Unread #4 - Jun 11, 2007 at 3:43 PM
  8. Jukka
    Joined:
    Nov 23, 2005
    Posts:
    244
    Referrals:
    0
    Sythe Gold:
    0

    Jukka Active Member

    Info Between Forms

    oh TY! ill try it now

    edit i got another problem. Look at my first post.
     
  9. Unread #5 - Jun 11, 2007 at 6:50 PM
  10. Darthatron
    Joined:
    May 22, 2006
    Posts:
    1,612
    Referrals:
    3
    Sythe Gold:
    0

    Darthatron Massive Troll
    Retired Sectional Moderator Visual Basic Programmers

    Info Between Forms

    Try declaring it like this in a module...
    Code:
    Global FileLocation, ScarCode as String
    And finally change your Command2_Click() to this...
    Code:
    Private Sub Command2_Click()
      FileLocation = Form1.Text1.Text
      Open FileLocation For Input As #1
      Print #1, ScarCode
      Close #1
    End Sub
    And for "ScarCode" try this, of course i presume its in form1...?
    Code:
    Form1.ScarCodeText.Text = ScarCode
    As you can see putting "Form1." before the "Text1.Text" tells VB that you want to interact with form1 and not the form that is currently open.
     
  11. Unread #6 - Jun 12, 2007 at 6:30 AM
  12. Jukka
    Joined:
    Nov 23, 2005
    Posts:
    244
    Referrals:
    0
    Sythe Gold:
    0

    Jukka Active Member

    Info Between Forms

    ty, ill test than now :?
     
  13. Unread #7 - Jun 12, 2007 at 8:13 AM
  14. Covey
    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    Info Between Forms

    You don't have to add it to a module.
    Example
    Form1 Code:
    Code:
    public blah as string
    
    private sub form_load()
    blah = "hi"
    end sub
    Form2 Code:
    Code:
    private sub form_load()
    msgbox form1.blah
    end sub
     
< buying a staker paying up 2 6m | Buying account, Real money involved! >

Users viewing this thread
1 guest


 
 
Adblock breaks this site