|
-
May 30th, 2000, 01:15 AM
#1
Thread Starter
Hyperactive Member
Hey guys check this out...i have a readme.txt in
\flag\documents\readme.txt
I want a command button to open it....i seem to be getting access errors everytime i use the open command....any help?
Note: If i understand correctly you have to put if its readonly or not...if so then make it readonly...also with the tips in the tip section all the open code gives me wrong path or file name and its in there....
-RaY
VB .Net 2010 (Ultimate)
-
May 30th, 2000, 01:38 AM
#2
New Member
Security
I have had those problems when trying to open files on computers at school due to their Fortres 101 security crap... any security programs on the computer you're running this app on? If not then maybe you're using the open command wrong. This is the format -
Code:
Private Sub Command1_Click()
Open "...\flag\documents\readme.txt" for Input as #1
Input #1, strVariable
Close #1
End Sub
That will put the contents of that readme.txt file into strVariable. If that doesn't help I don't know what to tell ya...
[Edited by ToneDogg on 05-30-2000 at 02:39 PM]
-
May 30th, 2000, 03:06 AM
#3
Yes, but if you require multiple lines, that method will not work. If you want multiple lines, the method below will work.
Make a Form with a CommandButton and a TextBox. Put the below code in the CommandButton
Code:
Private Sub Command1_Click()
' This will open the file and place the contents in
' a TextBox
Open "C:\MyFile.txt" For Input As #1
Text1 = Input(LOF(1), 1)
Close #1
End Sub
-
May 30th, 2000, 03:17 AM
#4
New Member
My experience...
My experience with partial paths has met with limited success. Sometimes the current directory isn't what I expect it to be, so (wrong or not) I always format as follows:
pathname = app.path & "\flag\documents\readme.txt"
and then open the file.
Hope that's helpful!
Shawn
-
May 30th, 2000, 04:31 AM
#5
Thread Starter
Hyperactive Member
ARGHHH
Ok guys, first i want to say the reason why i was getting a file not found is because i am using vb3 and the documents dir is more then 7 characters so it didn't recognize it!!!! After i figured that out i tried your code with the \flag\doc\readme.txt.......
First i tried tonedogg's didnt work...
then i tried you meth...it workssss however its one huge line with boxes for spaces and a big mess....I was under the assumption that notepad would just open up and show me the readme.txt..... is there a way to do that? If not how can i get the text to scroll down not one big bunch line.
-RaY
VB .Net 2010 (Ultimate)
-
May 30th, 2000, 04:51 AM
#6
Addicted Member
Well, I don't know if it works in VB3, but I use a Rich Text box and the code
Text1.Loadfile filename
where filename is a string containing the full path and name, e g "C:\vb98\flags\readme.txt" or whatever it is.
If you want the file opened by notepad I guess it could be done with the shell command, but I don't know hot.
Good luck,
Pentax
Wilhelm Tunemyr,
Swede in London
[email protected]
"Dort, wo man Bücher verbrennt, verbrennt man am Ende auch Menschen"
Heinrich Heine (1797-1856)
Pravda vítezi!
(Truth prevails!)
-
May 30th, 2000, 11:23 AM
#7
Conquistador
Code:
Open myFile for Input as #1
Do until Eof(1)
Input #1, myNewVar
myVar = MyNewVar & myVar
Loop
Close #1
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
|