|
-
Nov 18th, 2000, 03:03 PM
#1
Thread Starter
Lively Member
how would i open .txt file as open readonly so user can't change data.
-
Nov 18th, 2000, 03:17 PM
#2
Lively Member
you can't control that, yur best bet would be to make a text box in your program and lock it so no one can edit it
just make a new form with it in it or somehthing
I am stupid..but I AM 15 !
*a line from a song i wrote*
""""""""""""""""""""""""""""""""""""""""
so i came to say life bites away
whats done is done the past is gone
i cant believe the sh*t I know
i always wish it would just go
""""""""""""""""""""""""""""""""""""""""
"remember you Ps And Qs Boy !"
-
Nov 18th, 2000, 03:25 PM
#3
Check the "Open" command and just open it for "read". Then don't allow it to be saved. You tell the user as he opens the file that he will not be able to save changes.
-
Nov 18th, 2000, 03:36 PM
#4
_______
<?>
Code:
'if you want the file to be read only you can set
'the attributes and it would go like this.
Option Explicit
Public myFile As String
Private Sub Command1_Click()
myFile = "C:\my documents\myfile.txt"
SetAttr myFile, vbReadOnly
Shell "C:\WINDOWS\NOTEPAD.EXE " & myFile, 1
'now you can make changes and try to save the file
'and you won't be able to.
'you must reset the attributes when you close your app
'or the file will remain read only.
End Sub
'OR
'
'if you wish to use the textbox it goes like this
'
Private Sub Form_Load()
'add a textbox, set it to multiline and scrollbars
'Open a file in binary mode and read into a textbox or string
'this opens your file and dumps it into a textbox
'the user can do what they want but since it is only a textbox
'none of the changes will reflect inside the file
Dim sHolder As String
Dim intNum As Integer
Dim sFileName As String
'open for binary and read
sFileName = "C:\My Documents\MyFile.txt"
intNum = FreeFile
Open sFileName For Binary As intNum
sHolder = Space(LOF(1))
Get #1, , sHolder
Close intNum
'assign the text to a textbox
Text1 = sHolder ' for a string (strString = sholder)
End Sub
'this sets the file back to normal
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
SetAttr myFile, vbNormal
End Sub
Private Sub Form_Terminate()
SetAttr myFile, vbNormal
End Sub
Private Sub Form_Unload(Cancel As Integer)
SetAttr myFile, vbNormal
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
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
|