Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Public Variable confusion
Message
De
15/01/2013 10:31:03
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01562505
Message ID:
01562599
Vues:
27
Yes, you can address a public property, but only as a member of its class, in this case form1.
The problem is that form2 doesn't necessarily know anything about form1, so it can't necessarily say "form1.propertyx."
There are ways to make form1 visible to form2, but in general I prefer to encapsulate wherever possible, so I pass the value from one property to the other.

On the other hand if this is a sign on application, I use a static class property appuserclass.userid for the user ID. That makes it available any where in the project, almost the way public variables are in VFP.
All my VFP experience taught me to shun public variable, and as a rule I did.
This is the only time I've ever used a static class and it seems to work well.








>That's what I do, too. But I have to admit I don't know why PUBLIC doesn't work. I know PRIVATE memvars will fall out of scope in VFP but thought PUBLICs remained the same, i.e. they stay around until released or the session ends.
>
>>I usually put a similar property in the second form and populate it from the property in the first form after instantiating the second form.
>>
>>
>>
>>
>>>Hi Gang
>>>
>>>I have a variable (SCN) that is declared as a Public variable in the first form.
>>>
>>>Public Class Signon    'Form declaration
>>>  Public SCN as String
>>>  {Bunches of code here}
>>>
>>>  Private Sub cmdStart()
>>>    {more code here}
>>>    dim DispQuestion as new frmDispQuestion  'Create/call 2nd form here
>>>    DispQuestion.Show()
>>>  end sub
>>>end class
>>>
>>>
>>>
>>>First form calls second form which also needs to use SCN, but it doesn't recognize SCN as being declared in 2nd form. What do I need to do differently for the 2nd form to 'see' the SCN variable?
>>>
>>>Thanks
>>>Dorris
Anyone who does not go overboard- deserves to.
Malcolm Forbes, Sr.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform