|
-
Feb 5th, 2000, 05:35 AM
#1
Thread Starter
Addicted Member
Can anyone tell med how I can declare a variable, i.e. a string in the (General) in one form and use it in another form?
I have tried Form2.txt (where txt is the name of a string declared in the (general) of Form2) but it doesn't work.
Is there other ways to get information from one form to another?
Also:
How can I load the contents of a sequential file into a string? I have one method, loading it into a RichTextBox, but now I want it to get into the string without showing on the screen.
To read it line by line takes to much memory (and time) with big files.
Thanks in advance!
------------------
Wilhelm Tunemyr,
Sweden
[email protected]
"Dort, wo man Bücher verbrennt, verbrennt man am Ende auch Menchen"
Heinrich Heine (1797-1856)
Pravda zvítezi!
-
Feb 5th, 2000, 08:14 AM
#2
Addicted Member
To declare a variable for all forms you have to declare it as Public.
Just write Public instead of Dim.
For Example:
Public txt$
Then you can access the txt variable form everywhere in the application.
To load a text from a textfile:
Open Textfilename for Input as #1
Text1.text = Input(Lof(1), 1)
Close #1
This is really fast and puts all the content of the file into a textbox
------------------
Razzle
ICQ#: 31429438
-
Feb 5th, 2000, 09:58 AM
#3
Public variables are usually placed in the Declarations section of a code module rather than a form. That way you can use a naming scheme such as g_strMyVar where the g_ means that it's global (that is, available everywhere), and the str indicates that it's a String. If the variable where in the Declaration section of a form, it would be named m_strMyVar, where m_ is for module level.
As for your second question, read the fist line into a string variable, for example strMyVar, and then for all other reads say something like strMyVar = strMyVar & datafromnextread
------------------
Marty
What did the fish say when it hit the concrete wall?
> > > > > "Dam!"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|