Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.visual.basic    |    MS Visual Basic discussions, NOT dot-net    |    10,840 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 9,686 of 10,840    |
|    argusy to Geoff    |
|    Re: Newbie again- trouble with public va    |
|    08 Oct 05 07:14:44    |
   
   From: argusy@slmember.on.net   
      
   don't use ManName and change your form2 code to   
   txt1 = form1!txt1   
      
   If I remember my scope conditions correctly,   
   as ManName is defined in form1 (even though you've made it public),   
   it goes out of scope when hidden. ie, it "disappears".   
      
   Form1.txt1 is a different breed of fish - it retains it's info   
   unless you close form1 ("close me" instead of "me.hide")   
   all bets are off, in that case   
      
   Another way to get ManName retain its info is to put it   
   in a separate .bas file as a global variable   
   That's the "brute force" approach   
   It's a valid VB process, but many programmers frown on it   
   as it becomes another object that could create problems   
      
   Argusy   
      
      
   Geoff wrote:   
   > Any help would be really appreciated. What am I doing wrong? Simply trying   
   > to pass a string from Txt1 (a text box) on Form1 so that it appears in Txt2   
   > as Form2 loads   
   >   
   >   
   >   
   > '===========================================   
   >   
   > 'Code for form1   
   >   
   > Option Explicit   
   >   
   > Public ManName As String   
   >   
   >   
   >   
   > Private Sub But1_Click()   
   >   
   > Form2.Show   
   >   
   > Form1.Hide   
   >   
   >   
   >   
   > ManName = Me.Txt1   
   >   
   > End Sub   
   >   
   >   
   >   
   > '=============================================   
   >   
   > 'Code for Form2   
   >   
   > Option Explicit   
   >   
   >   
   >   
   > Private Sub Form_Load()   
   >   
   > Me.Txt2 = Form1.ManName   
   >   
   > End Sub   
   >   
   >   
   >   
   >   
   >   
   >   
   > Many thanks   
   >   
   >   
   >   
   > Geoff   
   >   
   >   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca