|
|
|
Работа с текстовым файлом
|
|||
|---|---|---|---|
|
#18+
Наткнулся случайно в Access XP (дурацкая там все-таки справка по сравнению с 97!!!) на интересный способ работы с текстовыми файлами. Нужно подключить библиотеку Microsoft Scripting Runtime, после чего становятся доступны такие объекты как FileSystemObject, TextStream...: На мой взгляд - это удобнее чем использование Open "TESTFILE" For Random As #1... Dim fs As FileSystemObject Dim a As TextStream dim source as string, str as string source = "c:\MyText.txt" Set fs = CreateObject("Scripting.FileSystemObject") Set a = fs.OpenTextFile(Source, ForReading, False) Do While Not a.AtEndOfStream str = a.ReadLine() Debug.Print str 'a.SkipLine Loop a.Close Самое интересное, что первоначальное назначение библиотеки - кодирование скриптов в веб-страницах для защиты от их незаконного копирования Вот пример, взятый с сайта microsoft Public Sub EncodePage() ' Sample encoder ' Andrew Clinick Jan 1999 ' Obviously this code could do with some error trapping etc ' but it should give you the basics to get started Dim strHTML As String ' Get the Frontpage document Dim mydoc As FPHTMLDocument ' Create a new instance of the scripting.encoder object Dim myEncoder As New Scripting.Encoder ' Get the current active document Set mydoc = ActiveDocument ' Get the HTML for the active document strHTML = mydoc.DocumentHTML ' Call the encodescriptfile method with the HTML strHTML = myEncoder.EncodeScriptFile(".htm", strHTML, 0, "") ' Set the documentHTML to be the return HTML with encoded script mydoc.DocumentHTML = strHTML ' We're done! End Sub ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 10.12.2003, 14:23 |
|
||
|
|

start [/forum/topic.php?fid=45&gotonew=1&tid=1677731]: |
0ms |
get settings: |
7ms |
get forum list: |
15ms |
check forum access: |
3ms |
check topic access: |
3ms |
track hit: |
146ms |
get topic data: |
8ms |
get first new msg: |
5ms |
get forum data: |
2ms |
get page messages: |
36ms |
get tp. blocked users: |
1ms |
| others: | 263ms |
| total: | 489ms |

| 0 / 0 |
