کلینیک فوق تخصصی اکسس ( کاربرد vba در اکسس )

کلینیک فوق تخصصی اکسس ( کاربرد vba در اکسس )

به اشتراک گذاری اطلاعات کسب شده در اکسس از سایت آفیس و سایت های تخصصی خارجی
کلینیک فوق تخصصی اکسس ( کاربرد vba در اکسس )

کلینیک فوق تخصصی اکسس ( کاربرد vba در اکسس )

به اشتراک گذاری اطلاعات کسب شده در اکسس از سایت آفیس و سایت های تخصصی خارجی

شئ OpenAsTextStream برای خواندن فایل متنی



باز کردن فایل مشخص شده و بازگشت یک شئ TextStream که می تواند برای خواندن از فایل ، نوشتن روی فایل یا اضافه کردن به فایل استفاده شود.


نوشتاری : 

object.OpenAsTextStream ([ iomode, [ format ]])

The OpenAsTextStream method syntax has these parts:


Object : بردن نام شئ ضروریست . همیشه نام شئ File

iomode : اختیاریست . حالت Input / Output را مشخص میکند و می تواند یکی از ۳ ثابت ForReading ، ForWriting و ForAppending باشد.

format : اختیاری ، برای نشان دادن فرمت فایل بازشده استفاده می شود. اگر خالی رها شود ، فایل در حالت ASCII باز میشود ... مثلا برای باز کردن به حالت پیش فرض عدد ثابت ۲- 





ConstantValueDescription
ForReading1Open a file for reading only. You can't write to this file.
ForWriting2Open a file for writing. If a file with the same name exists, its previous contents are overwritten.
ForAppending8Open a file and write to the end of the file.
ConstantValueDescription
TristateUseDefault-2Opens the file by using the system default.
TristateTrue-1Opens the file as Unicode.
TristateFalse0Opens the file as ASCII.

توضیحات : 

متد OpenAsTextStream مثل همان متد OpenTextFile از FileSystemObject عمل می کند . بعلاوه متد OpenAsTextStream می تواند برای نوشتن به فایل استفاده شود.


 
ReadReads a specified number of characters from a TextStream file and returns the result.
ReadAllReads an entire TextStream file and returns the result.
ReadLineReads one line from a TextStream file and returns the result.
SkipSkips a specified number of characters when reading a TextStream file.



For large files, using the ReadAll method wastes memory resources. Other techniques should be used to input a file, such as reading a file line-by-line.



' const ForReading=1

Set fso =CreateObject("Scripting.FileSystemObject")
Set fileObject =fs.GetFile("test1.txt")
Set  myfile=fileObject.OpenAsTextStream(ForReading, TristateUseDefault)
Magbox myfile.ReadAll
myfile.Close






strFile_Path = "Your file Path"
Open strFile_Path For Append As #1
Write #1, “You can write your required text here”
Close # 1












نظرات 0 + ارسال نظر
برای نمایش آواتار خود در این وبلاگ در سایت Gravatar.com ثبت نام کنید. (راهنما)
ایمیل شما بعد از ثبت نمایش داده نخواهد شد