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,688 of 10,840    |
|    Max Healey to Geoff    |
|    Re: Newbie again- trouble with public va    |
|    08 Oct 05 10:04:32    |
   
   From: ok@spam-me.com   
      
   It's simply a timing issue   
      
   you are passing the value of txt1 to your public string AFTER you are   
   calling the form2 load so the on load event would fire before the variable   
   was set to the value of txt1 so it would be blank, if you step through the   
   app you would see that the it is doing exactly as you asked it.   
      
      
   However the right way to do it would be as suggested by another poster   
   simply set the txt2 on form 2 to form.txt1.   
      
   You will notice that the controls on a form are available publicly while a   
   form is loaded, calling a value from a form that is not loaded will in fact   
   load it but not display it. so you may be better to declare a public   
   vairable in a module to store your global settings so you don't end up with   
   an app that will not close due to circular references.   
      
      
      
      
      
      
      
   "Geoff" wrote in message   
   news:zdKdnc5sWta0UtveRVnyug@brightview.com...   
   > 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