Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding a user input field from 1 form to another

Status
Not open for further replies.

MaTtRiX

IS-IT--Management
Aug 8, 2000
9
0
0
US
Hi,
I am trying to take a user inputer field (a username) from 1 form, and add it into a text file along with other data that they have entered in another form. I have tried Dim usern as string, but when i try to recall it in another form, it does not show up. Is there a way to do this, am i not adding in the variables correctly?
Thanks in advance!

Mike [sig][/sig]
 
You could either address it with the form name as in
'form1.txtusername' or you could use a global variable. For a global variable you need to put 'Public usern as string' in a module. [sig]<p>David Paulson<br><a href=mailto: > </a><br><a href= > </a><br> [/sig]
 
Good call, David. Mike, just remember that all variables are private unless you declare them otherwise at the module level or reference them explicitly from another procedure.

This is VB's way of eliminating confusion, even though it might create a little confusion at first.
[sig]<p> <br><a href=mailto: > </a><br><a href= plain black box</a><br>Don't sit down. It's time to dig another one.[/sig]
 
Also, if you want to keep things more modular, you can add properties to a form to access the variable (a form follows the same rules as a class module):

Private m_strMyString As String

Public Property Get MyString() As String
MyString=m_strMyString
End Property

' from outside module
Dim str
str=myForm.MyString

This would be the more OOP way to do it. Even though VB is quite a ways from being truly object oriented ;)

Regards, [sig]<p>Russ<br><a href=mailto:bobbitts@hotmail.com>bobbitts@hotmail.com</a><br><a href= is in</a><br>[/sig]
 
Thanks guys. Im really new to this, and this is really helping me understand alot about VB. And one question more (if ya dont mind) what would a truly object oriented language be?

Thanks for all the help guys!! I really appreciate your input, and the help im receiving. Im really liking the Tek-Tips site :) [sig][/sig]
 
It depends on your definition of OOP. In Windows world, where there is only COM for communication bwtween components, VC++, VB, VJ++ are all OOP, but if you mean traditional OOP definition VB is not one, since it does not support inheritance, but VC++ and VJ++ are.
This is not a problem in VB, since the inheritance is the start of problems if you are not aware of them. But if you are serious using inheritance, good news is that the next version of Visual Studio (.NET) will support it. For more info take a look at : [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top