|
-
Jul 10th, 2000, 02:23 PM
#1
Thread Starter
Frenzied Member
I got 2 forms:
form1
and
form2
in form1 I tell it to make a file called C:\b.dat
in form2 I tell it read from the file c:\b.dat at form load
As soon as I run the program it says
error 51, file not found
it says that because the file doesn't exist yet
so what do I do
if you dont know what I mean, I could try to explain it another way
NXSupport - Your one-stop source for computer help
-
Jul 10th, 2000, 02:28 PM
#2
Did you create the file before you read form it?
-
Jul 10th, 2000, 02:32 PM
#3
Thread Starter
Frenzied Member
The first form that starts is form 1
then the suer fills in the information, and clicks OK
then it writes the file c:\b.dat
and loads form2
at form load of form to, it reads the file c:\b.dat and puts the information of that file into labels
but as soon as I clikc RUN>START
the error message comes up, when I click debug, it goes to the code of form2
and the yello thing is pointed to where it says to read c:\b.dat
please help
NXSupport - Your one-stop source for computer help
-
Jul 10th, 2000, 02:38 PM
#4
What are you using to read and write the bat file?
And you could use the Dir function to check if the file exists and if it doesn't than write it.
-
Jul 10th, 2000, 02:40 PM
#5
Thread Starter
Frenzied Member
you don't get it:
a form writes a file
another forms reads it
the problem is that vb detets that the file that form1 was supposed to qrite to doesn't exsist yet (because form1 didnt write to it)
NXSupport - Your one-stop source for computer help
-
Jul 10th, 2000, 02:40 PM
#6
Thread Starter
Frenzied Member
if you want I can email you the forms
NXSupport - Your one-stop source for computer help
-
Jul 10th, 2000, 02:50 PM
#7
Lively Member
ok, so first of all:
if u are using the Open statement then:
when you open a file or output it creates the file, otherwise (input) doesn't
if you are using another way to open the file, please tell me so that i can tell u what to do, ok?
byt,
yair
-
Jul 10th, 2000, 02:53 PM
#8
Thread Starter
Frenzied Member
i guess I can't explain myself, so
want me to email it to you?
just leave your email, and I will send it ASAP
(same to megatron, and matt)
NXSupport - Your one-stop source for computer help
-
Jul 10th, 2000, 02:54 PM
#9
Lively Member
ok,
then can u send me the forms on email??
to [email protected]
or
[email protected]
bye,
yair
-
Jul 10th, 2000, 02:59 PM
#10
Thread Starter
Frenzied Member
NXSupport - Your one-stop source for computer help
-
Jul 10th, 2000, 03:04 PM
#11
Hyperactive Member
If I understand you right, this should solve your problem:
In form1:
Code:
Private Sub Command1_Click()
Open "c:\windows\desktop\temp.txt" For Append As #1
Print #1, Text1.Text
Close #1
Form2.Show
End Sub
In form2
Code:
Private Sub Form_Load()
Dim fso, sTemp(1)
Set fso = CreateObject("scripting.FileSystemObject")
Do While fso.FileExists("c:\windows\desktop\temp.txt") = False
DoEvents
Loop
Set sTemp(0) = fso.GetFile("c:\windows\desktop\temp.txt")
Set sTemp(1) = sTemp(0).OpenAsTextStream(1, -2)
sVar = sTemp(1).ReadAll
Label1.Caption = sVar
End Sub
Hope this helps
-
Jul 10th, 2000, 03:09 PM
#12
You do not need to e-mail your Form. It's only the Open statement that would be giving the Error.
To Write to the file. (If it doesn't exsist, It will be created)
Code:
Open "C:\b.dat" For Output As #1
Write #1, "One", "Two", "Three"
Close #1
To Read the file
Code:
Open "C:\b.dat" For Input As #1
Input #1, A, B, C
Close #1
Label1 = A
Label2 = B
Label3 = C
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
|