ตรวจสอบว่ามีไฟล์หรือไม่
กระทู้เก่าบอร์ด อ.Yeadram

 1,585   3
URL.หัวข้อ / URL
ตรวจสอบว่ามีไฟล์หรือไม่

ผมเจอปัญหาอย่างหนึ่งครับ คือ
    ลองหาข้อมูลแล้ว ได้มาจากกระทู้ นี้
    http://www.thai-access.com/yeadram_view.php?topic_id=2172
    แต่ไม่ตรงกับความต้องการที่จะใช้ครับ เพราะผมใช้โปรแกรมเพื่อดึ่งค่าของID มาอ่านเป็นชื่อไฟล์แล้วใส่นามสกุลแบบบังคับเพื่อการใช้งานเลยครับ
ตามตัวอย่าง....
                 sFileName = AppPath &"\" [DocID] & ".pdf"
     แล้วเขียนโปรแกรมเพื่อ ให้ดับเบิ้ลคลิ๊ก เพื่อเปิดไฟล์ปลายทางที่กำหนด แต่จะ เกิด error ขึ้นถ้าไม่มีไฟล์ปลายทางครับ
    .... คำถามคือ มีคำสั่งสำหรับตรวจสอบไฟล์ปลายทาง ว่ามีอยู่จริงจะตรวจสอบได้อย่างไรครับ

3 Reply in this Topic. Dispaly 1 pages and you are on page number 1

1 @R11841
Dir[(pathname[, attributes])]

vbNormal     = 0 = (Default) Specifies files with no attributes.
vbReadOnly = 1 = Specifies read-only files in addition to files with no attributes.
vbHidden     = 2 = Specifies hidden files in addition to files with no attributes.
VbSystem    = 4 = Specifies system files in addition to files with no attributes. Not available on the Macintosh.
vbVolume    = 8 = Specifies volume label; if any other attributed is specified, vbVolume is ignored. Not available on the Macintosh.
vbDirectory = 16 = Specifies directories or folders in addition to files with no attributes.
vbAlias        = 64 = Specified file name is an alias. Available only on the Macintosh.


If Dir("C:\Temp", vbDirectory) = "" Then
     Msgbox "ไม่มีชื่อโฟลเดอร์นี้"
Else
     Msgbox "มีชื่อโฟลเดอร์นี้จริง"
End If


If Dir("C:\Temp\Text.txt", vbNormal) = "" Then
     Msgbox "ไม่มีไฟล์ชื่อนี้อยู่จริง"
Else
     Msgbox "มีไฟล์นี้อยู่จริง"
End If
2 @R11842
ขอบคุณมากครับ
3 @R12742
ใช้ได้แล้วครับ ขบอคุณมากจิงๆที่แบ่งบัน
@ ประกาศใช้งานเว็บบอร์ดใหม่ => บอร์ดเรียนรู้ Access สำหรับคนไทย
แล้วจะใส่ลิ้งอ้างอิงมาที่โพสต์เก่านี้หรือไม่ก็ตามสะดวกครับ
Time: 0.3128s