PowerPoint Presentation

Similar documents
2010年3月计算机等级考试四级网络工程师笔试

全国计算机技术与软件专业技术资格(水平)考试

1 1 Excel VBA 說明 ( ) (_) STEP4 Excel 2 STEP5 A1 1 B2 2 C3 3 STEP6 A1 STEP7 > > 1-11

Microsoft PowerPoint - VB14.ppt

VB程序设计教程

2

壹 前 言 解 開 2048 的 謎 一 研 究 動 機 最 近 我 們 都 很 熱 衷 於 2048 這 款 遊 戲, 遊 戲 方 法 非 常 簡 單, 但 是 想 要 達 成 2048 卻 很 難, 每 次 只 差 臨 門 一 腳 就 能 達 到 2048, 因 此 都 沒 有 成 功 過 於

TwinCAT 1. TwinCAT TwinCAT PLC PLC IEC TwinCAT TwinCAT Masc

VB控件教程大全

投稿類別:電子工程類

ThreeDtunnel.doc

Visual Basic D 3D

Outline USB Application Requirements Variable Definition Communications Code for VB Code for Keil C Practice

Microsoft Word - 小心翼翼的二十一點N.doc

穨文件1

untitled

White Sketchpad PowerPoint Presentation

MVB-1001.DOC

untitled

PowerPoint Presentation

Guide to Install SATA Hard Disks

WinMDI 28

<4D F736F F D205BCAE9B0FCCDF85DC8FDC9FAC8FDCAC0CAAEC0EFCCD2BBA82E646F6378>

Microsoft Word - template.doc

K7VT2_QIG_v3

Microsoft Word - 扉页








1

Excel VBA Excel Visual Basic for Application

C H A P T E R 7 Windows Vista Windows Vista Windows Vista FAT16 FAT32 NTFS NTFS New Technology File System NTFS

任務二 : 產生 20 個有炸彈的磚塊, 放在隨機的位置編輯 Block 類別的程式碼 import greenfoot.; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) Write a description of class

<4D F736F F D D342DA57CA7DEA447B14D2DA475B57BBB50BADEB27AC3FEB14DA447B8D5C344>

(Microsoft Word - \302\315\301n\272\241\276\360\300Y2.doc)

2012年目录文件目录.xls

els0xu_zh_nf_v8.book Page Wednesday, June, 009 9:5 AM ELS-0/0C.8

二、文选

苏教高〔2005〕 号

3 Driver do Microsoft Access (*.mdb) hisdata IFIX 1.4

四川省普通高等学校

GoFlex Home UG Book.book

ebook140-9

2009年3月二级VB语言笔试真题

27 :OPC 45 [4] (Automation Interface Standard), (Costom Interface Standard), OPC 2,,, VB Delphi OPC, OPC C++, OPC OPC OPC, [1] 1 OPC 1.1 OPC OPC(OLE f

Microsoft Word - 專題製作研究報告書.doc

投影片 1

主程式 : public class Main3Activity extends AppCompatActivity { ListView listview; // 先整理資料來源,listitem.xml 需要傳入三種資料 : 圖片 狗狗名字 狗狗生日 // 狗狗圖片 int[] pic =new

第 一 节 认 识 自 我 的 意 义 一 个 人 只 有 认 识 自 我, 才 能 够 正 确 地 认 识 到 自 己 的 优 劣 势, 找 出 自 己 的 职 业 亮 点, 为 自 己 的 顺 利 求 职 推 波 助 澜 ; 一 个 人 只 有 认 识 自 我, 才 能 在 求 职 中 保 持

Spyder Anaconda Spyder Python Spyder Python Spyder Spyder Spyder 開始 \ 所有程式 \ Anaconda3 (64-bit) \ Spyder Spyder IPython Python IPython Sp

untitled

Visual Basic AD/DA Visual Basic 2

untitled

Microsoft Word - DCS-5220_線上監視平台-說明手冊_1.00_T_.doc

商 业 城 大 华 标 准 70 万 70 万 驰 宏 锌 锗 瑞 华 标 准 140 万 150 万 亚 星 锚 链 江 苏 公 证 天 业 标 准 80 万 80

欢迎辞

金 陵 饭 店 中 兴 华 已 报 备 按 照 国 资 委 要 求 定 期 轮 换 天 衡 已 报 备 按 照 国 资 委 要 求 定 期 轮 换 *ST 中 富 中 喜 已 报 备 业 务 约 定 书 到 期 普

辉 丰 股 份 重 大 事 项, 特 停 南 方 轴 承 临 时 停 牌 德 力 股 份 临 时 停 牌 瑞 丰 光 电 临 时 停 牌 联 建 光 电 临 时 停 牌 卡 奴 迪 路 临 时 停 牌

日 涨 幅 偏 离 值 达 到 7% 的 前 五 只 证 券 : 温 氏 股 份 ( 代 码 ) 涨 幅 偏 离 值 :11.68% 成 交 量 :1752 万 股 成 交 金 额 : 万 元 机 构 专 用 机 构 专 用

上市公司股东大会投票信息公告( )

东 华 能 源 江 苏 苏 亚 金 诚 已 报 备 因 地 域 及 审 计 时 间 安 排 等 原 因 中 兴 华 已 报 备 客 户 重 新 选 聘 会 计 师 事 务 所 亿 帆 鑫 富 立 信 已 报 备 客

昆 明 机 床 瑞 华 已 报 备 前 任 服 务 年 限 较 长 毕 马 威 华 振 已 报 备 未 与 客 户 未 就 2015 年 审 计 收 费 达 成 一 致 意 见 中 国 核 电 天 健 已 报 备 定

光 一 科 技 重 大 事 项, 特 停 茂 业 商 业 重 要 事 项 未 公 告, 连 续 停 牌 浙 富 控 股 重 大 事 项, 特 停 键 桥 通 讯 重 大 事 项, 特 停 黑 牛 食 品 重 大 事 项, 特 停

郑 州 煤 电 重 要 事 项 未 公 告, 连 续 停 牌 金 圆 股 份 重 大 事 项, 特 停 永 鼎 股 份 重 要 事 项 未 公 告, 连 续 停 牌 长 城 影 视 临 时 停 牌 天 兴 仪 表 临 时 停 牌

卧 龙 地 产 重 要 事 项 未 公 告, 连 续 停 牌 春 兴 精 工 临 时 停 牌 *ST 沧 大 重 要 事 项 未 公 告, 连 续 停 牌 天 地 源 重 要 事 项 未 公 告, 连 续 停 牌 汇 冠 股 份

金 圆 股 份 重 大 事 项, 特 停 长 城 影 视 临 时 停 牌 天 兴 仪 表 临 时 停 牌 商 赢 环 球 重 要 事 项 未 公 告, 连 续 停 牌 荣 安 地 产 临 时 停 牌 中 南 文 化

Untitled Document

股票代码: 股票简称:*ST新梅 编号:临

金 利 科 技 临 时 停 牌 凤 凰 光 学 重 要 事 项 未 公 告, 连 续 停 牌 安 源 煤 业 重 要 事 项 未 公 告, 连 续 停 牌 万 泽 股 份 临 时 停 牌 爱 康 科 技 重 大 事 项, 特 停

Microsoft Word - PS2_linux_guide_cn.doc

概述


SP5 user guide.PDF

1 Framework.NET Framework Microsoft Windows.NET Framework.NET Framework NOTE.NET NET Framework.NET Framework 2.0 ( 3 ).NET Framework 2.0.NET F

RAID RAID 0 RAID 1 RAID 5 RAID * ( -1)* ( /2)* No Yes Yes Yes A. B. BIOS SATA C. RAID BIOS RAID ( ) D. SATA RAID/AHCI ( ) SATA M.2 SSD ( )

台 中 市 北 屯 區 東 山 里 橫 坑 9 林 志 明 巷 89-5 菜 豆 菜 大 漿 果 菜 豆 菜 大 漿 果 小 漿 果 核 果 柑 桔 無 陳 錦 生 新 竹 市 香 山 區

菩提道次第廣論

路 上 沒 說 話, 車 子 被 爸 離 去 後 開 走 了, 沒 什 麼 變, 除 了 一 股 淡 淡 的 香 味, 我 不 太 習 慣, 像 空 氣 中 的 粉 塵, 左 飄 右 飄, 光 中 飛 舞 我 沒 提, 看 車 窗 外, 外 面 不 太 有 趣, 我 只 是 沒 事 幹, 我 們 本

繁 華 國 小 101 學 年 母 親 節 感 恩 惜 福 - 跳 蚤 市 場 暨 科 學 闖 關 遊 戲 親 子 活 動 實 施 計 畫 一 依 據 : 本 校 101 學 年 度 校 務 計 畫 及 行 事 曆 二 目 的 : 1. 培 養 學 生 感 恩 惜 物 知 福 惜 福 的 節 儉 觀


育儿小故事(四)

untitled

ebook65-5

ebook140-8

Microsoft Word - Sable User's Manual.doc

《Visual Basic程序设计》实验课

Cadence SPB 15.2 VOICE Cadence SPB 15.2 PC Cadence 3 (1) CD1 1of 2 (2) CD2 2of 2 (3) CD3 Concept HDL 1of 1

Visual C# 2005程式設計

<4D F736F F D20A5F1A4FBA473A6DBA662C149AE76BB50B0A8AFAAB944A440AC78A67BA976C149BEC7ABE4B751AABAB56FAE692E646F63>


Sun Fire V440 Server Administration Guide - zh_TW

科学计算的语言-FORTRAN95

epub 61-2

Windows 2000 Server for T100

untitled

Transcription:

Visual Basic 程式設計 檔案存取 檔案控制項元件 File System Objects

DriveList 屬性 Drive List ListCount ListIndex 目前磁碟機代碼可選擇磁碟機可選擇磁碟機個數已選擇的磁碟機的位置 事件 Change 所選擇的磁碟機改變時 2

DriveListBox (cont.) Private Sub Drive1_Change() Print Drive1.Drive Print Drive1.List(Drive1.ListIndex) Print Drive1.ListCount Print Drive1.ListIndex Private Sub form_click() Drive1.Drive = "c:" 3

DirListBox 屬性 Path 目前目錄 List 可選擇目錄 ListCount 目前目錄下可選擇目錄個數 ListIndex 已選擇目錄的位置 事件 Change 所選擇的目錄改變時 4

Private Sub Dir1_Change() MsgBox (Dir1.Path) Private Sub form_click() Cls Print Dir1.Path Print Dir1.ListCount Print Dir1.List(Dir1.ListIndex) Print Dir1.List(0) 5

FileListBox 屬性 FileName 已選擇檔案的檔名 Path 目前目錄 List 可選擇檔案 ListCount 目前目錄下可選擇檔案數目 ListIndex 已選擇檔案的位置 MultiSelect 可否重複選擇 Selected( 數字 ) 某個元素是否有被選 Pattern 要顯示的檔案型態 ( 過濾方式 ), 如 :*.* 或 *.txt 6

FileListBox (cont.) 事件 Click PatternChange PathChange 目前目錄改變時 7

FileListBox (cont.) Private Sub File1_Click() Print File1.FileName Print File1.Path Print File1.Path + "\" + File1.FileName Private Sub Form_Activate() File1.Path = "c:\temp" 8

整合 DriveList FileListBox DirListBox 9

整合 (cont.) Private Sub updatepath() Text1.Text = Dir1.Path + File1.FileName Private Sub Command1_Click() File1.Pattern = Text2.Text Private Sub Drive1_Change() Dir1.Path = Drive1.Drive 10

整合 (cont.) Private Sub Dir1_change() File1.Path = Dir1.Path updatepath Private Sub File1_click() updatepath 11

Visual Basic 程式設計 檔案存取 檔案控制項元件 File System Objects

File System Objects 13

File System Objects (cont.) File System Objects 共有五種物件 FileSystemObject File Folder Drive TextStream 14

FileSystemObject (cont.) 屬性 Drives 傳回目前本機上的磁碟機的 collection 方法 CopyFile CopyFolder CreateFolder CreateTextFile DeleteFile 複製檔案複製目錄產生新檔案產生新文字檔刪除檔案 15

FileSystemObject (cont.) 方法 DeleteFolder 刪除目錄 DriveExists 回傳磁碟機是否存在 FileExists 回傳檔案是否存在 FolderExists 回傳目錄是否存在 GetAbsolutePathName 取得絕對路徑名 GetDrive 取得 Drive 物件 GetDriveName 取得磁碟機名 GetFile 取得 File 物件 16

FileSystemObject (cont.) 方法 GetFileName 取得檔案名 GetFolder 取得 Folder 物件 GetParentFolderName 取得父目錄名 GetTempName 取得暫存檔檔名 MoveFile 搬移檔案 MoveFolder 搬移目錄 OpenTextFile 開啟文字檔 17

FileSystemObject (cont.) 產生新的 FileSystemObject Dim 變數名 As New FileSystemObject Drive, Folder, File, TextStream 亦同 CopyFile 來源, 目的 [, 覆蓋模式 ] 來源 目的 : 字串 覆蓋模式 : boolean, 預設值為 true 來源 目的可用 * 與? 18

FileSystemObject (cont.) Private Sub form_click() Dim fs As New FileSystemObject fs.copyfile "c:\autoexec.bat", "c:\test", _ False 19

FileSystemObject (cont.) CopyFolder 來源, 目的 [, 覆蓋模式 ] 將來源目錄下所有的檔案 目錄, 複製到目的目錄 CopyFolder c:\temp, c:\tmp 將來源目錄下某些目錄複製到目的目錄 Copy Folder c:\temp\a*, c:\tmp 20

FileSystemObject (cont.) CreateFolder 目錄名 產生新目錄 若目錄已存在, 則發生錯誤 CreateTextFile 檔名 [, 覆蓋模式 ] 產生新檔案 傳回 TextStream Private Sub form_click() Dim fs As New FileSystemObject fs.createfolder "c:\a" fs.createtextfile "c:\a\test" 21

FileSystemObject (cont.) DeleteFile 檔名 [, force] 檔名可包含 * 與? 若 force=false, 則無法刪除屬性是 read only 的檔案 DeleteFolder 目錄名 [, force] 目錄名可包含 * 與? 若 force=false, 則無法刪除屬性是 read only 的目錄 即使目錄內有檔案也會刪除 22

FileSystemObject (cont.) Private Sub Command1_Click() Dim fs As New FileSystemObject fs.deletefile File1.Path + "\" + _ File1.FileName File1.Refresh Private Sub Dir1_Change() File1.Path = Dir1.Path Private Sub Drive1_Change() Dir1.Path = Drive1.Drive 23

FileSystemObject (cont.) DriveExists 磁碟機名 檢查該磁碟機是否存在 DriveExists c: 若 CDROM 沒有光碟片, 也會回傳 true 要用 Drive 物件的 IsReady 來偵測 FileExists 檔案名 FolderExists 目錄名 24

FileSystemObject (cont.) GetAbsolutePathName 路徑名 目錄名 c: c:.. 回傳值 c:\mydocuments\reports c:\mydocuments\ c:*.*\may97 c:\mydocuments\reports\*.*\may 97 region1 c:\mydocuments\reports\region1 25

FileSystemObject (cont.) GetDrive 磁碟機名 回傳 Drive 物件 GetDriveName 磁碟機名 GetFile 檔案名 回傳 File 物件 GetFileName 路徑名 26

FileSystemObject (cont.) GetFolder 目錄名 回傳 Folder 物件 GetParentFolderName 路徑名 GetParentFolderName( c:\a\b\c ) c:\a\b GetTempName MoveFile 來源, 目的 MoveFolder 來源, 目的 27

FileSystemObject (cont.) OpenTextFile 檔名 [, IO 模式 [,create]] IO 模式 ForReading ForAppending Create: 若檔案不存在, 是否開新檔案 傳回 TextStream 28

FileSystemObject (cont.) 29

Private Sub Dir1_Change() File1.Path = Dir1.Path Private Sub Drive1_Change() Dir1.Path = Drive1.Drive Private Sub File1_Click() Dim fs As New FileSystemObject Text1.Text = "GetDriveName: " + _ fs.getdrivename(file1.path) _ + vbnewline + _ "GetParentFolderName: " + _ fs.getparentfoldername(file1.path) _ + vbnewline + _ "GetTempName: " + fs.gettempname() 30

Drive AvailableSpace 可用空間大小 (bytes) DriveLetter 磁碟機代碼 DriveType 磁碟機型別 FileSystem 檔案系統 FreeSpace 剩餘空間大小 (bytes) IsReady TotalSize 總體空間大小 (bytes) 31

Drive (cont.) DriveType 0:Unknown( 未知 ) 1:Removable( 磁片 ) 2:Fixed( 硬碟 ) 3:Network( 網路磁碟機 ) 4:CD-ROM 5:RAM-DISK 32

Drive (cont.) 程式還沒完 Private Sub Drive1_Change() Dim fs As New FileSystemObject Dim drv As Drive Set drv = fs.getdrive( _ Mid(Drive1.Drive, 1, 2)) Cls If (Not drv.isready) Then MsgBox "Drive is not ready" Exit Sub End If Print drv.availablespace; " bytes" Print drv.driveletter 33

Drive (cont.) Select Case drv.drivetype Case 0: Print "Unknown" Case 1: Print "Removable" Case 2: Print "Fixed" Case 3: Print "Network" Case 4: Print "CD-ROM" Case 5: Print "RAM Disk" End Select Print drv.filesystem Print drv.freespace; " bytes" Print drv.isready Print drv.totalsize; "bytes" 34

File DateCreate 檔案產生日期 DateLastAccessed 最近被讀取 / 更改日期 DateLastModified 最近被更改日期 Drive 所在磁碟機 Size 檔案大小 Path 路徑名 Name 檔名 方法 OpenAsTextStream 開啟檔案 35

Folder DateCreate 檔案產生日期 DateLastAccessed 最近被讀取 / 更改日期 DateLastModified 最近被更改日期 Drive 所在磁碟機 Size 檔案大小 Path 路徑名 Name 檔名 36

File and Folder 37

File and Folder (cont.) Dim fs As New FileSystemObject Private Sub Drive1_Change() Dim drv As Drive Set drv = fs.getdrive(drive1.drive) If (Not drv.isready) Then MsgBox "Drive is not ready!" Dir1.Enabled = False File1.Enabled = False Exit Sub End If Dir1.Enabled = True File1.Enabled = True Dir1.Path = Drive1.Drive 程式還沒完 38

File and Folder (cont.) Private Sub dir1_change() Dim dir As Folder File1.Path = Dir1.Path Cls Set dir = fs.getfolder(dir1.path) Print dir.datecreated Print dir.datelastaccessed Print dir.datelastmodified Print dir.size Private Sub file1_click() Dim fl As file Cls Set fl = fs.getfile(file1.path + "\" + _ File1.FileName) Print fl.datecreated Print fl.datelastaccessed Print fl.datelastmodified Print fl.size 39

TextStream ( 循序檔 ) 產生方法 [File].OpenAsTextStream [FileSystemObject].OpenTextFile 屬性 AtEndOfLine AtEndOfStream Column Line 傳回是否在最後一行傳回是否在檔尾目前位置目前在第幾行 40

TextStream (cont.) 方法 Close Read ReadAll ReadLine Skip SkipLine Write WriteBlankLines WriteLine 關閉檔案讀取某數量的字元 ( 傳回 String) 讀取全部內容 ( 傳回 String) 讀一行跳過某數量的字元跳過幾行寫入一個 String 寫入幾個空白行寫入一行 41

TextStream (cont.) Private Sub Command1_Click() Dim fs As New FileSystemObject Dim st As TextStream If (Not fs.fileexists(text1.text)) Then MsgBox "File does not exist!!" Exit Sub End If Set st = fs.opentextfile(text1.text, _ ForReading) MsgBox st.read(2),, "Read" MsgBox st.readline,, "ReadLine" MsgBox st.readall,, "ReadAll" 42

小小編輯器 43

小小編輯器 (cont.) Dim filename As String Dim fs As New FileSystemObject Private Sub readfile() Dim st As TextStream Set st = fs.opentextfile(filename, ForReading) Text1.Text = st.readall() Private Sub writefile() Dim st As TextStream fs.deletefile (filename) Set st = fs.opentextfile(filename, _ ForAppending, True) st.writeline (Text1.Text) 程式還沒完 44

小小編輯器 (cont.) Private Sub Command1_Click() CommonDialog1.Filter = " 文字檔 (*.txt) *.txt" CommonDialog1.ShowOpen filename = CommonDialog1.fileName If (filename = "") Then Exit Sub End If readfile Text1.Enabled = True Command1.Enabled = False Command2.Enabled = True Private Sub Command2_Click() writefile Text1.Text = "" tetx1.enabled = False Command1.Enabled = True Command2.Enabled = False 45