Adblock breaks this site

Info Between Forms

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

  1. Jukka

    Jukka Active Member

    Joined:
    Nov 23, 2005
    Posts:
    244
    Referrals:
    0
    Sythe Gold:
    0
    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
     
  2. timk777

    timk777 Active Member

    Joined:
    Feb 19, 2007
    Posts:
    156
    Referrals:
    0
    Sythe Gold:
    0
    Info Between Forms

    Declare it in a module,

    Public FileLocation as string
     
  3. speljohan

    speljohan Guru
    Visual Basic Programmers

    Joined:
    Apr 24, 2005
    Posts:
    1,450
    Referrals:
    3
    Sythe Gold:
    0
    Info Between Forms

    if this was in vb.net it could easily be achieved by adding a constructor for Form1.
     
  4. Jukka

    Jukka Active Member

    Joined:
    Nov 23, 2005
    Posts:
    244
    Referrals:
    0
    Sythe Gold:
    0
    Info Between Forms

    oh TY! ill try it now

    edit i got another problem. Look at my first post.
     
  5. Darthatron

    Darthatron Massive Troll
    Retired Sectional Moderator Visual Basic Programmers

    Joined:
    May 22, 2006
    Posts:
    1,612
    Referrals:
    3
    Sythe Gold:
    0
    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.
     
  6. Jukka

    Jukka Active Member

    Joined:
    Nov 23, 2005
    Posts:
    244
    Referrals:
    0
    Sythe Gold:
    0
    Info Between Forms

    ty, ill test than now :?
     
  7. Covey

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816
    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! >


 
 
Adblock breaks this site