Ps22Pdf

Similar documents
SMM667.mps

VB程序设计教程

四川省普通高等学校

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

Microsoft Word - 扉页

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

2

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

Microsoft PowerPoint - OPVB1基本VB.ppt

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

<4D F736F F D D342DA57CA7DEA447B14D2DA475B57BBB50BADEB27AC3FEB14DA447B8D5C344>

Microsoft PowerPoint - Chapter5

PowerPoint Presentation

Microsoft Word - 24.doc

Microsoft Word - 扉页.doc

2007年4月全国计算机二级考试VB语言笔试真题

untitled

<4D F736F F D20B8DF2DB4A8BDCCBAAF373530BAC5A3A8BAECCDB7A3A92E646F63>

投稿類別:電子工程類

全国计算机等级考试无纸化真考题库试卷(3)

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

untitled

<4D F736F F D20B3CCD0F2D4B12DCFC2CEE7CCE2A3AD3037C9CF>

上海市教育考试院关于印发新修订的

單元5

<4D F736F F D20B3CCD0F2D4B12DC9CFCEE7CCE2A3AD3037C9CF>

FY.DOC


User’s Manual


Microsoft Word - CIN-DLL.doc

科学计算的语言-FORTRAN95

典型自编教材

(Microsoft Word - \253\312\255\261)

untitled

ebook111-4

多層次傳銷與獎金系統

Microsoft Word - 改版式网页全文.doc

Microsoft Word - 扉页.doc

Microsoft Word - 序.DOC

Microsoft Word htm

精 品 库 我 们 的 都 是 精 品 _www.jingpinwenku.com D. 以 上 三 个 都 是 (11) 在 窗 体 ( 名 称 为 Form1) 上 画 一 个 名 称 为 Text1 的 文 本 框 和 一 个 名 称 为 Command1 的 命 令 按 钮, 然 后 编 写

24 第 3 章 创 建 Access 数 据 库 和 表 3.1 创 建 Access 数 据 库 Access 2003 中 的 数 据 库 属 于 关 系 型 数 据 库, 以.mdb 为 文 件 的 后 缀, 建 立 一 个 数 据 库 的 同 时, 就 创 建 了 数 据 库 中 的 对

jsj0.nps

吳元康

麻 省 理 工 學 院 是 在 西 元 2013 年 12 月 3 日 推 出 MIT App Inventor 2 網 站, 提 供 免 費 的 雲 端 服 務, 使 用 者 可 以 透 過 瀏 覽 器 來 開 發 Android 裝 置 應 用 程 式, 該 網 站 的 網 址 為 : http

PowerPoint Presentation

教 學 綱 要 表 1-1 多 媒 體 應 用 科 目 大 要 學 分 數 :2 建 議 開 課 學 期 : 第 九 十 八 學 年 第 二 學 期 本 科 目 教 學 目 標 在 培 養 學 生 影 像 製 作 及 影 像 剪 輯 等 多 媒 體 應 用 之 興 趣 與 能 力, 並 能 在 生

(Guangzhou) AIT Co, Ltd V 110V [ ]! 2

JC2.nps

目 录 第 一 章 工 程 的 建 立 1.1 新 建 工 程 画 面 编 辑... 2 第 二 章 画 面 传 输 2.1 传 输 设 置 画 面 传 输 方 式 模 拟 操 作... 9 第 三 章 常 用 Parts 介 绍 3.1 位 开

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

Microsoft Word - 01.DOC


Microsoft Word - 益智小遊戲之研究~2048.docx

SDP

13 根 据 各 种 网 络 商 务 信 息 对 不 同 用 户 所 产 生 的 使 用 效 用, 网 络 商 务 信 息 大 致 可 分 为 四 级, 其 中 占 比 重 最 大 的 是 ( A ) A 第 一 级 免 费 信 息 B 第 二 级 低 收 费 信 息 C 第 三 级 标 准 收 费

一、在PowerPoint中实现对象翻转

Microsoft Word - 13院21号.doc

本 课 程 作 为 非 计 算 机 专 业 本 科 通 识 课 程, 是 一 门 理 论 和 实 践 紧 密 结 合 的 实 用 课 程, 内 容 包 括 计 算 机 基 础 部 分 和 程 序 设 计 部 分 计 算 机 基 础 部 分 涵 盖 计 算 机 软 硬 件 组 成 数 制 表 示 操

序号

前言

高 职 计 算 机 类 优 秀 教 材 书 目 * 序 号 书 号 (ISBN) 书 名 作 者 定 价 出 版 / 印 刷 日 期 ** 配 套 资 源 页 码 计 算 机 基 础 课 计 算 机 应 用 基 础 刘 升 贵 年 8 月

Microsoft Word 年4月ACCESS真卷.doc

Microsoft Word - 09.數學 docx

扉页.doc

Microsoft Word htm

2014年全国计算机二级Access预测试卷 2

CLOUDYBI云库用户界面使用说明

(Microsoft Word -

Microsoft Word - 财务d08z.doc

Microsoft Word - PS2_linux_guide_cn.doc

epub 61-2

Microsoft Word - InoTouch Editor编程软件手册 doc

Symantec™ Sygate Enterprise Protection 防护代理安装使用指南


ebook140-8

Microsoft Word - 3D手册2.doc

untitled

17 Image Composer WWW Internet?..., WWW,,,,? FrontPage Editor,, ; Front Page Editor, : ;, :..., Image Composer Front Page 98,,! Image Composer,! Image

6

Post-Secondary Student Summer Internship Programme 2016_Chi

Name of Government Department

计算机在汉语研究中的应用――以字频统计为例

全 国 高 等 职 业 教 育 规 划 教 材 21 世 纪 高 职 高 专 规 划 教 材 系 列 高 等 职 业 教 育 计 算 机 专 业 规 划 教 材 选 题 征 集 通 知 一 选 题 范 围 ( 不 仅 限 于 此 ) 选 题 方 向 选 题 名 计 算 机 基 础 计 算 机 应 用

目 录 目 录 1. 安 装 和 快 速 入 门 附 件 1.1 随 机 附 件 附 件 信 息... 3 连 接 和 设 定 1.3 连 接 记 录 纸... 4 快 速 入 门 1.5 发 送 传 真 / 复 印 接 收 传 真

(京)新登字063号

第 3 章 数 据 在 计 算 机 中 的 表 示 43 在 进 位 计 数 制 中 有 数 码 数 位 ( 位 置 ) 基 数 和 位 权 等 用 语 数 码 是 在 一 个 计 数 制 中 用 来 表 示 数 值 的 符 号 ; 数 位 是 指 数 码 在 一 个 数 中 所 处 的 位 置 ;

提问袁小兵:

2 熟 悉 Visual Basic 的 集 成 开 发 环 境 3 了 解 可 视 化 面 向 对 象 编 程 事 件 驱 动 交 互 式 开 发 等 基 本 概 念 4 了 解 Visual Basic 的 特 点 环 境 要 求 与 安 装 方 法 1 Visual Basic 开 发 应 用

ebook 132-2

Microsoft Word Äê¼Æ»ú¶þ¼¶±ÊÊÔÊÔÌâ.doc

- -1 個 人 電 腦 介 面 卡 製 作 流 程 一 第 一 站 詴 場 每 個 工 作 崗 位 考 前 均 會 提 供 個 人 電 腦 介 面 卡 成 品, 如 下 圖 -1 所 示, 目 的 是 讓 應 檢 人 檢 查 個 人 電 腦 USB 設 備 以 及 三 顆 IC 是 否 正 常 (

一 個 SQL Injection 實 例 的 啟 示 頁 2 / 6 因 此, 在 知 名 網 站 上 看 到 SQL Injection, 讓 人 驚 心, 卻 不 意 外 網 站 專 案 外 包 是 目 前 業 界 的 常 態, 而 在 價 格 取 勝 的 制 度 下, 低 價 得 標 的 S

高尔夫赌博现金棋牌,能赚现金的棋牌游戏 街机赌博游戏 真钱的棋牌游戏,30

ebook40-16

Microsoft Word - 11.doc

摘 要 在 這 忙 碌 的 社 會 中, 普 遍 人 們 運 動 時 間 其 實 並 不 充 裕, 體 力 越 來 越 差 的 情 況 下 還 隨 意 飲 食 導 致 身 體 健 康 越 來 越 差, 因 此 本 專 題 打 算 利 用 健 康 飲 食 的 方 式 改 善 這 些 人 的 體 質,

自动化接口


Transcription:

Visua l Ba sic 6

( ) 158,,,, Windows ;,, A 6, ; B,, Visual Basic, W indows 95/ 98,, : Visual Basic 6 : : (, 100084) : : : 787 1092 1/ 16 : 23. 75 : 578 : 2002 1 1 2002 1 1 : 0001 5000 : ISBN 7 302 05015 5/ T P 2908 : 32. 00

Visual Basic Visual Basic Visual Basic Visual Basic 6.0 1 2 Windows 3 Visual FoxPro Delphi 4 6 Visual Basic Windows 95 98 VB Visual Basic 6.0

21 C C++ C PASCAL 1. 2. 3. 4. 21 21 licb@public wh.hb.cn x_fb@163.net 2001

1 VB 1 1. 1 VB 1 1. 2 VB 2 1. 3 VB 4 1. 3. 1 4 1. 3. 2 5 1. 3. 3 5 1. 3. 4 6 1. 3. 5 6 1. 4 6 1. 4. 1 7 1. 4. 2 8 1. 4. 3 8 1. 4. 4 10 1. 4. 5 10 1. 4. 6 12 1. 5 1 12 2 VB 13 2. 1 13 2. 1. 1 13 2. 1. 2 14 2. 1. 3 16 2. 1. 4 16 2. 1. 5 17 2. 1. 6 18 2. 2 18 2. 2. 1 18 2. 2. 2 19 2. 2. 3 19 2. 2. 4 21 2. 2. 5 21 2. 2. 6 23 2. 3 VB 24 2. 3. 1 24 2. 3. 2 25 2. 3. 3 26 2. 3. 4 27 2. 3. 5 28 2. 3. 6 28 2. 4 2 29 3 VB 30 3. 1 30 3. 1. 1 30 3. 1. 2 30 3. 1. 3 32 3. 2 33 3. 2. 1 33 3. 2. 2 35 3. 2. 3 37 3. 3 39 3. 3. 1 40 3. 3. 2 41 3. 4 43 3. 4. 1 43 3. 4. 2 Print 44 3. 4. 3 Rem 46 3. 4. 4 End 47 3. 5 47 3. 5. 1 If 48 3. 5. 2 Select Case 50 3. 6 52 3. 6. 1 For 52 3. 6. 2 While 54 3. 6. 3 Do 55 3. 6. 4 57 3. 7 58 3. 7. 1 58 3. 7. 2 59

3. 7. 3 60 3. 7. 4 62 3. 8 VB 64 3. 8. 1 Input Box 64 3. 8. 2 MsgBox 66 3. 8. 3 67 3. 9 3 70 4 74 4. 1 74 4. 1. 1 74 4. 1. 2 75 4. 1. 3 75 4. 2 76 4. 2. 1 76 4. 2. 2 77 4. 2. 3 77 4. 3 79 4. 3. 1 79 4. 3. 2 80 4. 3. 3 80 4. 4 82 4. 4. 1 82 4. 4. 2 82 4. 4. 3 82 4. 5 83 4. 5. 1 83 4. 5. 2 84 4. 5. 3 84 4. 6 85 4. 6. 1 85 4. 6. 2 85 4. 6. 3 85 4. 7 86 4. 7. 1 86 4. 7. 2 86 4. 7. 3 86 4. 8 87 4. 8. 1 87 4. 8. 2 88 4. 8. 3 88 4. 9 89 4. 9. 1 89 4. 9. 2 90 4. 9. 3 90 4. 10 90 4. 10. 1 90 4. 10. 2 91 4. 10. 3 91 4. 11 92 4. 11. 1 92 4. 11. 2 93 4. 11. 3 94 4. 12 95 4. 12. 1 95 4. 12. 2 96 4. 12. 3 96 4. 13 97 4. 13. 1 97 4. 13. 2 97 4. 13. 3 97 4. 14 98 4. 14. 1 98 4. 14. 2 99 4. 14. 3 99 4. 15 100 4. 15. 1 101 4. 15. 2 101 4. 15. 3 102 4. 16 103 4. 17 4 105 5 109 5. 1 109 5. 1. 1 109 5. 1. 2 111 5. 1. 3 111 5. 1. 4 112 5. 1. 5 114 5. 1. 6 T ab 114 5. 1. 7 115 5. 2 117 5. 2. 1 118 5. 2. 2 120 5. 2. 3 120 5. 2. 4 120

5. 3 125 5. 3. 1 126 5. 3. 2 126 5. 4 128 5. 4. 1 MDI 128 5. 4. 2 MDI 129 5. 4. 3 MDI 129 5. 4. 4 MDI 129 5. 4. 5 MDI 130 5. 5 5 133 6 135 6. 1 135 6. 1. 1 135 6. 1. 2 138 6. 2 140 6. 2. 1 140 6. 2. 2 143 6. 3 155 6. 3. 1 155 6. 3. 2 157 6. 3. 3 159 6. 4 6 160 7 162 7. 1 162 7. 1. 1 162 7. 1. 2 162 7. 1. 3 163 7. 2 163 7. 2. 1 163 7. 2. 2 164 7. 2. 3 164 7. 2. 4 165 7. 2. 5 165 7. 3 167 7. 3. 1 167 7. 3. 2 167 7. 3. 3 168 7. 3. 4 168 7. 3. 5 168 7. 3. 6 169 7. 4 170 7. 4. 1 171 7. 4. 2 171 7. 4. 3 171 7. 4. 4 171 7. 5 7 174 8 176 8. 1 176 8. 1. 1 176 8. 1. 2 178 8. 1. 3 179 8. 2 181 8. 2. 1 182 8. 2. 2 183 8. 3 187 8. 3. 1 188 8. 3. 2 188 8. 3. 3 189 8. 3. 4 189 8. 3. 5 191 8. 4 193 8. 4. 1 193 8. 4. 2 196 8. 5 8 197 9 200 9. 1 200 9. 1. 1 200 9. 1. 2 201 9. 2 203 9. 2. 1 203 9. 2. 2 204 9. 2. 3 205 9. 2. 4 208 9. 2. 5 208 9. 3 208 9. 3. 1 209 9. 3. 2 210 9. 3. 3 213 9. 4 9 216

10 VB 217 10. 1 217 10. 1. 1 217 10. 1. 2 218 10. 1. 3 ( SQL) 219 10. 1. 4 219 10. 1. 5 ODBC 219 10. 2 221 10. 2. 1 221 10. 2. 2 222 10. 2. 3 225 10. 2. 4 226 10. 3 Dat a 228 10. 3. 1 Data 228 10. 3. 2 Data 229 10. 3. 3 Data 230 10. 3. 4 Recordset 230 10. 3. 5 Data 231 10. 4 DBGrid 234 10. 4. 1 DBGrid 235 10. 4. 2 DBGrid 236 10. 4. 3 DBGrid 237 10. 4. 4 DBGrid 237 10. 5 ADO Dat a 239 10. 5. 1 ADO Data 240 10. 5. 2 ADO Data 243 10. 5. 3 ADO Data 244 10. 5. 4 ADO Data 244 10. 6 ( SQL ) 248 10. 6. 1 SQL 248 10. 6. 2 248 10. 6. 3 SQL 249 10. 7 10 250 11 DAO 252 11. 1 DAO 252 11. 2 DBE ngine 252 11. 2. 1 DBE ngine 253 11. 2. 2 DBE ngine 254 11. 2. 3 DBE ngine 255 11. 3 Workspace 255 11. 3. 1 W orkspace 255 11. 3. 2 W orkspace 256 11. 3. 3 W orkspace 257 11. 4 Dat abase 258 11. 4. 1 Database 258 11. 4. 2 Database 258 11. 4. 3 T abledef 260 11. 4. 4 Recordset 261 11. 4. 5 QueryDef 265 11. 4. 6 Database 266 11. 5 Field 270 11. 5. 1 Field 271 11. 5. 2 Field 271 11. 5. 3 Field 272 11. 6 Index 272 11. 6. 1 Index 272 11. 6. 2 Index 272 11. 6. 3 Index 273 11. 7 DAO 273 11. 7. 1 273 11. 7. 2 274 11. 8 11 281 12 ADO 283 12. 1 ADO 283 12. 2 Connect ion 284 12. 2. 1 Connection 285 12. 2. 2 Connection 286 12. 3 Recordset 287 12. 3. 1 Recordset 287 12. 3. 2 Recordset 288 12. 4 Command 290 12. 4. 1 Command 290 12. 4. 2 Command 290 12. 4. 3 Command Parameter 291 12. 4. 4 Command 291 12. 5 ADO 293 12. 6 12 300

A 301 1 VB 301 2 304 3 309 4 312 5 315 6 322 B 326 1 326 2 327 3 329 4 334 5 340 6 343 7 345 8 349 9 351 10 355 11 359 12 363

1 VB Visual Basic Visual Basic 1.1 VB Visual Basic Basic Visual Basic BASIC Visual Basic Internet 1991 VB1.0 6.0 5.0 DOS Windows 3.x 16 5.0 Windows 9.x NT 32 VB 6.0 VB 6.0 Internet Internet Intranet Internet IIS HTML DHTML Web SQL ActiveX ADO

2 Visual Basic VB 6.0 3 VB VB Microsoft Windows Windows NT VB VB VB VB ActiveX Internet HTML VB VB VB BackOffice SQL Server 1.2 VB VB Microsoft Visual Basic 6.0 Microsoft Visual Basic 6.0 VB VB 1.1 1.1 VB VB EXE ActiveX EXE ActiveX

1 VB 3 ActiveX DLL ActiveX DLL ActiveX EXE ActiveX ActiveX VB VB IIS IIS ActiveX ActiveX VB Web Internet Explorer DHTML DHTML VB VB 1.1 3 EXE VB 1.2 1.2 Visual Basic 6.0

4 Visual Basic VB 1.3 VB VB 1.2 5 5 VB VB 5 5 1.3.1 VB 1. 1-Microsoft Visual Basic[ ] VB 3 1 2 3 Windows 9.x 2. 13 1 2 3 4 5 6 7 8 9 10 11 12

1 VB 5 13 VB 3. VB 1.3 VB 1.3.2 1.3 VB 1.2.vbp.frm.bas.cls 1.3.3 1.2 1 2

6 Visual Basic 3 4 1.3.4 1.2 VB VB Form1 Form2 1.3.5 1.2 VB 1.4 VB 1.4 6

1 VB 7 1.4.1 1.4 1.4 1. VB VB Option Explicit Tab 1 32 4 2.

8 Visual Basic 1.4.2 VB 1.5 1.5 1.4.3 VB 1.6

1 VB 9 1.6 VB VB VB ActiveX ActiveX ActiveX

10 Visual Basic VB 1.4.4 1.7 1.7 MDI 1.4.5 VB 1.8

1 VB 11 1.8 Windows VB Visual Basic VB (.exe) VB F5 F5 VB VB MDI 7

12 Visual Basic 1.4.6 VB 1.9 1.9 SDI MDI SDI VB SDI 1.5 1 1.1 VB 1.2 VB 1.3 VB 1.4 VB 1.5 VB

2 VB VB VB VB 2.1 VB VB 2.1.1 VB VB VB VB VB 2.1 2.2

14 Visual Basic 2.1 VB 2.1.2 2.2

2 VB 15 VB 2.1 2.3 2.1 Name Caption Left Top Width Height BorderStyle Font Enabled Visible MousePointer TabIndex Appearance BackColor ToolTipText 2.3

16 Visual Basic 2.1.3 Windows DOS Windows Timer VB 2.2 2.2 Click DblClick Load Unload Resize Change KeyDown KeyUp KeyPress MouseDown MouseUp MouseMove 2.1.4 Sub _ ()

2 VB 17 Command1 Text1 Sub Command1_Click Text1.Text=" " VB VB BASIC Command1 2.4 2.1.5 2.4 [.] [ ] Form1 Print Form1.Print " "

18 Visual Basic 2.1.6 Basic VB VB VB Click Click 1 2 Load 3 4 2.2 VB VB 2.2.1 1.vbp 2.vbg 3.frm 4

2 VB 19.bas Public 5 Visual Basic.cls 6 2.2.2 1. 1 2 3 4 2. 2.2.3 1.

20 Visual Basic 1 2 3 1 2 3 2. 1 2 3. 1 2

2 VB 21 2.2.4 1. VB VB 1 2 2.5 2.5 2. VB VB VB 2.2.5

22 Visual Basic 1. F2 Ctrl + Tab Ctrl + Tab 2. 2.6 2.6

2 VB 23 3. 1 2 2.2.6.exe 1. F5

24 Visual Basic Shift + F5 2. 1.exe 2.exe 3.exe Windows 95 2.3 VB VB 4 1 2 3 4 2.3.1 EXE VB VB VB VB

2 VB 25 1 2 3 4 5 Form1 2.7 2.3.2 2.7 Form1 1 2 3 Shift Top Left Ctrl

26 Visual Basic Ctrl Top Left 2.3.3 2.3 1 2 3 Form1 Form1 Caption example Text1 Text Text1 Command1 Caption Form1 2.8

2 VB 27 2.8 Form1 2.3.4 VB VB Name _ Command1 Command1_Click Form1 Command1 2.9

28 Visual Basic 2.3.5 2.9 F5 2.10 2.11 2.10 2.3.6 2.11

2 VB 29 VB Form1 example 2.4 2 2.1? 2.2 2.3 2.4 2.5 51 2.6 2.12 2.12

3 VB VB VB VB VB 3.1 VB VB 3.1.1 VB 255 VB VB VB As Binary ByRef ByVal Date Else Empty Error False For Friend Get Input Is Len Let Lock Me Mid New Next Nothing Null On Option Optional ParamArray Print Private Property Public Resume Seek Set Static Step String Then Time To True WithEvents 3.1.2 VB VB VB

3 VB 31 1. VB VB = = 2. VB 3.1 VB 3.1 VB ^ - * / \ Mod + - & 3. 3.2 VB 3.2 VB = <> > < >= <=

32 Visual Basic Like Is 4. 3.3 VB Not 3.3 VB Not And Or Xor Eqv Imp 3.1.3 VB 1. VB VB VB VB 2. _ 255 3. Rem '

3 VB 33 3.2 VB VB VB 3.2.1 VB 1. " ( ) c1="a":c2=cl+"1":c3="" 2. 5 1 0 9-32 768~+32 767-5 12 345 0 0 9 A F a f &H 4 &H0 &HFFFF 0 7 &0 & 6 &0~&0177777 2-2 147 483 648~+2 147 483 647 &H &H0&~&FFFFFFF& &O &O0&~&O37777777777&

34 Visual Basic 3 3.141593 123.45-100.05 0.0 4 E D 10 1.23E+10-1.23D+10 0.5E-24-0.52E8 5 0 255 96 100 0 3. True( ) False( ) 4. # #12/18/2000# 5. 1 VB VB VBA 2 VB Const [Public Private] Const < > [As < >]=< > < > < > Const PI=3.14159265358979 Public Const CMax As Integer = 9 Const IDate = #11/30/2000#

3 VB 35 Public Const A = B * 2 Public Const B = A / 2 3.2.2 VB 1. VB 1 Option Explicit 2 Option Explicit 1 Dim [As ] 2 Static [As ] 3

36 Visual Basic Private [As ] 4 Public [As ] Module1 x Module2 x Module1 x Module1.x Module2 x Module2.x 2. = X X = 5 X = Y X = X + 1 Y X 3. Y X Y X Y X X = Y

3 VB 37 3.2.3 Variant VB 1. Integer Long Single Double Currency Integer Long Long Integer Single Double Double Single 15 4 2. 3. 1 Dim X As Integer Dim Y As String Y = "10.23" X = Y Y = X + 1 X 10.23 Y 11.23

38 Visual Basic 4. True False Yes No On Off 5. Date # Dim TestDate As Date TestDate=#11/30/2000# TestDate=#2000-11-30# TestDate=#11/30/2000 10:47:29 pm# 6. Variant Variant VB Dim a' Variant a="20" 'a "20"( ) a=a-15 ',a 5 a="c"&a ',a "C5" ( ) Variant Variant Variant Variant & + Variant 3 Empty Null Error 1 Empty Variant Empty IsEmpty Empty If IsEmpty(x) Then x=0 Empty 0 ("") Null Variant Empty 0 ( 0 Null) Variant Empty Empty Variant Variant Empty 2 Null Null Null

3 VB 39 Null Null Null Null Null Null Null Variant Null Null Null Null x=null IsNull Variant Null If IsNull(x) And lsnull(y) Then z=null Else z=0 End If Null Variant Null Variant Null Variant ( Null ) Variant Null 3 Error Error CVErr Error 7. (Object) Object Set Object Dim objdb As Object Set objdb=opendatabase("c:\vb6\student.mdb") Object TextBox Control Database Object VB 3.3 VB Variant

40 Visual Basic 3.3.1 1. 1 Private 2 Private 3 Public 2. 0 Long [Private Public] -1 As -1 0-1 7 A Private A 6 As Integer To 7 1 7 A Private A(1 To 7) As Integer 3. Variant Variant Dim intx As Integer Dim countersa 5 As Integer For intx = 0 To 4 countersa(intx)=5 Next intx Dim countersb 5 As String For intx = 0 To 4

3 VB 41 countersb(intx) = "hello" Next intx Dim arrx 2 As Variant arrx 1 = countersa() arrx 2 = countersb() 4. VB 10 10 Dim Matrix(9,9) as Double Dim Matrix(1 To 9,1 To 9) as Double Variant 3.3.2 Public Dim Static Dim 1 MatrixX Dim MatrixX 2 ReDim ReDim -1 MatrixX 9 ReDim MatrixX 8 X=8 ReDim MatrixX X Preserve MatrixX

42 Visual Basic ReDim Preserve MatrixX 15 3.1 4 3 3 Form1 Private Sub Form_Load() Show Dim student 5 As String * 8 Dim score(5, 5) As Single student 1 = " ": student 2 = " ": student 3 = " " student 4 = " ": student 5 = " " score(1, 1) = 68: score(1, 2) = 84: score(1, 3) = 79 score(2, 1) = 89: score(2, 2) = 92: score(2, 3) = 90 score(3, 1) = 86: score(3, 2) = 69: score(3, 3) = 72 score(4, 1) = 76: score(4, 2) = 62: score(4, 3) = 60 FontSize = 14: FontName = " ": FontUnderline = True Print Print Tab(14); " " Print FontSize = 10: FontName = " ": FontUnderline = False Print " "; Tab(12); " "; Tab(20); " "; Tab(28); " "; _ Tab(36); " "; Tab(44); " " For i = 1 To 4 ' score(i, 4) = score(i, 1) + score(i, 2) + score(i, 3) score(i, 5) = score(i, 4) / 3 Next For i = 1 To 5 ' score(5, i) = (score(1, i) + score(2, i) + score(3, i) + score(4, i)) / 4 Next i For i = 1 To 4 ' Print student(i); Print Tab(12); Format(score(i, 1), "###.0"); Print Tab(20); Format(score(i, 2), "###.0"); Print Tab(28); Format(score(i, 3), "###.0"); Print Tab(36); Format(score(i, 4), "###.0"); Print Tab(44); Format(score(i, 5), "###.0") Next Print FontUnderline = True Print Trim(student(i)); ' Print Tab(12); Format(score(5, 1), "###.0"); Print Tab(20); Format(score(5, 2), "###.0"); Print Tab(28); Format(score(5, 3), "###.0");

3 VB 43 Print Tab(36); Format(score(5, 4), "###.0"); Print Tab(44); Format(score(5, 5), "###.0") student score 3.1 3.1 Form1 3.4 VB 3.4.1 [Let] = Let Single

44 Visual Basic = = = = x = y ' y x y = x ' x y z=x+y x+y=z = x+y x = 2 : y = x : z = x x y z 2 x = 5 x = x + 1 x 5 1 6 x st st = "Good" st = st & "morning" st "Good morning" VB 0 3.4.2 Print Print Print BASIC PRINT [.]Print[ ][, ] (Debug) (Printer) Form1.Print "Visual Basic" ' Form1 "Visual Basic" Picture1.Print "Visual Basic" ' Picture1 "Visual Basic" Print "Visual Basic" ' "Visual Basic"

3 VB 45 Print Print "aa"&"bb",2*6 ' aabb 12 Print "aa"&"bb";2*6 ' aabb12 Print 14 Print Print Print Print VB Print 1 Tab Tab Print Print# Tab(n) n 1 n n n Mod n 1 Tab n Tab Print Tab(10); " ";Tab(30);" " Print Tab Tab 2 Spc Print Print# Spc n : Spc(n) n Spc Print "ABC";Spc(5); "DEP" ' ABC DFE Print Spc Spc Tab Tab Spc Spc Space Spc

46 Visual Basic 3.2 Print Form2 Private Sub Form_Click() Print "aa" & "bb", 2 * 6 Print "aa" & "bb"; 2 * 6 Print Print Now ' Print FontSize = 16 ' Print "12*5="; 12 * 5 Print FontSize = 12 Print "12*5=", 12 * 5 Print FontSize = 14 FontBold = True ' Print " "; FontSize = 10 Print " " Form2 3.2 3.4.3 Rem 3.2 Form2 Rem '

3 VB 47 Rem Rem ' Rem 3.4.4 End End End End End Stop End Unload QueryUnload Terminate VB End VB End Private Sub Form_Load Dim Password,Pword As String Password = "640129" Pword=InputBox(" ") If Pword<>Password Then MsgBox " " End End If End 3.5 VB If Select Case

48 Visual Basic 3.5.1 If If 1. If If Then 1 [Else 2] Else Then 1 If Else Else 2 If If Private Function MaxValue1(a As Integer,b As Integer) As Integer If a > b Then MaxValue1 = a Else MaxValue1 = b End Function 2. If 1 If Then End If Then If If If Private Function MaxValue2(a As Integer,b As Integer) As Integer If a > b Then MaxValue2 = a End If If a<=b Then MaxValue2 = b End If End Function

3 VB 49 2 If Then 1 Else 2 End If Then 1 If If Else 2 If Private Function MaxValue3(a As Integer,b As Integer) As Integer If a > b Then MaxValue3 = a Else MaxValue3 = b End If End Function 3 If 1 Then 1 ElseIf 2 Then 2 [ElseIf 3 Then 3] [Else n] End If ElseIf ElseIf 3.4

50 Visual Basic 3.4 90 80 70 60 60 Private Function Level1(x As Integer) As String If x>=90 Then Level1 = " " ElseIf x>=80 Then Level1 = " " ElseIf x>=70 Then Level1 = " " ElseIf x>=60 Then Level1 = " " Else Level1 = " " End If 3.5.2 Select Case If VB Select Case If If Select Case Select Case Select Case Case 1 1 [Case 2 2] [Case Else n]

3 VB 51 End Select Case Select Case Select Case Case Else Select Case Select Case Select Case Case 1 Case 1 Case "char" 2 1[ 2] [ n] Case Case 1,3,5,7 Case "a", "b", "c", "d" 3 1 To 2 1 2 Case 1 To 4 Case "a" To "z" 4 Is Is = < > <= >= <> Case Is < 3 Case Is > "Apple" Case Is < 5 7 8 9 Is > 12 Case Is < "z", "A" To "Z" Select Case Case Case

52 Visual Basic Select Case Case Else Case Case Case Select Case Select Case Private Function Level2(x As Integer) As String Select Case x Case Is>=90 Level2 = " " Case Is>=80 Level2 = " " Case Is>=70 Level2 = " " Case Is>=60 Level2 = " " Case Else Level2 = " " End Select 3.6 For While Do 3.6.1 For For For For = To [Step ] [ ] [Exit For] [ ] Next 1

3 VB 53 2 3 4 1 Step 5 6 Exit For For 7 Next For For For Exit For Exit For For Exit For For For 1 n Private Function Sum1(n As Integer) As Integer Dim s,i As Integer For i=1 To n s=s+i Next i Sum1=s End Function 3.3 Form3 Private Sub Form_Click() FontSize = 12 Print Tab(35); " "

54 Visual Basic Print Tab(33); "-------------" For i = 1 To 9 For j = 1 To i Print Tab((j - 1) * 9 + 1); i & "*" & j & "=" & i * j; Next j Print Next i 3.3 3.3 Form3 For For For Each in [ ] Next [ ] Next Private Sub Command1_Click For Each Control in Me.Controls Print Control.Name Next Control 3.6.2 While While For For

3 VB 55 While While While While [ ] Wend True False Wend While 1 n While Private Function Sum2(n As Integer) As Integer Dim s,i As Integer i=1 While (i<=n) s=s+i:i=i+1 Wend Sum2=s End Function 3.6.3 Do Do While While Do Do 1 Do [ ] ['

56 Visual Basic Exit Do] [ ] Loop [While Until ] 2 Do [While Until ] [ ] [' Exit Do] [ ] Loop Do 1 For While 2 Exit Do Do Exit Do Do 3 Do Loop Exit Do 4 Do For While 5 While Until 1 While Until While Until 2 Loop

3 VB 57 1 n Do Private Function Sum3(n As Integer) As Integer Dim s,i As Integer If n=1 Then Sum3=1 Else i=1 Do s=s+i:i=i+1 Loop (i<=n) Sum3=s End If End Function Private Function Sum4(n As Integer) As Integer Dim s,i As Integer i=1 Do While (i<=n) s=s+i:i=i+1 Loop Sum4=s Loop End Function 3.6.4 VB 1 Exit For For For For If Then Exit For 2 Exit Do Do 3 Exit Sub Sub 4 Exit Function Function

58 Visual Basic 1 n Exit Do Private Function Sum5(n As Integer) As Integer Dim s,i As Integer i=1 Do If (i>n) Then Exit Do s=s+i:i=i+1 Loop Sum5=s End Function 3.7 VB 3.7.1 Sub [Private Public][Static]Sub Sub Public VB 1. 3.4 Click Gen() Click

3 VB 59 Command1_Click() Command2_Click() Command3_Click() Gen() 3.4 2. VB Name _ Command1 Command1_Click Form Form_Click MDI MDIForm MDIForm_Load Private Sub _ ( ) [ ] Private Sub Form MDIForm_ ( ) [ ] VB Name VB 3.7.2 VB Sqr Sin Chr Function Function

60 Visual Basic [Private Public][Static]Function ( ) [As ] [ ] Sub Function Function Sub Function 1 = 2 As Variant 3 Function Function Area(a As Single, b As Single, c As Single) As Single Dim s As Single s = (a + b + c) / 2 Area = Sqr(s * (s - a) * (s - b) * (s - c)) End Function VB Function 4 3 4 Area Private Sub Command1_Click() Text4.Text = Area(Val(Text1.Text), Val(Text2.Text), Val(Text3.Text)) 3.7.3 1. Sub Function Sub getdata() Function avgdata() VB

3 VB 61 2. Sub Function Sub Sub Function Sub Sub Call Sub ( ) Sub Call Call 3. VB = ( ) Call ( ) VB 4. 1 Form1 SomeSub Form1 Call Form1.SomeSub( ) 2 DemoClass Class1 Dim DemoClass As New Class1 DemoClass.SomeSub DemoClass 3

62 Visual Basic Module1 Module2 CommonName Module2 CommonName Module2 CommonName Module1 CommonName Module2 Module1 CommonName Module1.CommonName( ) 3.7.4 1. Variant Function Sqrtab1(a As Single,b as Single) a=a*a:b=b*b Sqrtab=Sqr(a+b) End Function 2. ByVal Function Sqrtab2(ByVal a As Single,ByVal b as Single) a=a*a:b=b*b Sqrtab=Sqr(a+b) End Function 3. VB VB Sqrtab1 a b x y Sqrtab1

3 VB 63 Sub Comp() Dim x As Single Dim y As Single Dim z As Single x=3:y=4 z=sqrtab1(x,y) ' x=9,y=16 Sqrtab1 x y Sqrtab1 Sub Comp() Dim x As Single Dim y As Single Dim z As Single x=3:y=4 z=sqrtab1((x),(y)) ' x y 4. Optional Optional c Function CompAdd1(a As Integer,b As Integer,Optional c As Integer) If IsMissing(c) Then CompAdd1=a+b+c Else CompAdd1=a+b End If End Function IsMissing Empty x=compadd1(2,3) ' x 5 y=compadd1(2,3,4) ' y 9 5. c 10 Function CompAdd2(a As Integer,b As Integer,Optional c As Integer=10)

64 Visual Basic CompAdd2=a+b+c End Function x=compadd2(2,3) ' x 15 y=compadd2(2,3,4) ' y 9 6. ParamArray CompAdd3 Dim x As Variant Dim s As Integer Dim intsum As Integer Function CompAdd3(ParamArray intnums()) For Each x In intnums s=s+x Next x CompAdd3=s End Function x=compadd3(2,3,4,5) y=compadd3(1,3) ' x 14 ' y 4 3.8 VB VB 3.8.1 InputBox 1 InputBox(prompt[,title][,default][,xpos,ypos][,helpfile,context]) 2

3 VB 65 InputBox$(prompt[,title][,default][,xpos,ypos][,helpfile,context]) $ prompt 1024 title default xpos twip 1 =1440 ypos twip xpos ypos helpfile readme.hlp C:\readme.hlp context helpfile 3.5 Private Sub Command1_Click() m = InputBox(" 0 100 ", " ", "80") 3.5

66 Visual Basic 3.8.2 MsgBox VB InputBox MsgBox MsgBox MsgBox MsgBox(prompt[,buttons][,title][,helpfile,context]) title helpfile context Inputbox prompt 1024 1024 buttons 3.5 3.5 button vbokonly 0 OK vbokcancel 1 OK Cancel vbabortretryignore 2 Abort Retry Ignore vbyesnocancel 3 Yes No Cancel vbyesno vbretrycancel 4 5 Yes No Retry Cancel VbCritical 16 VbQuestion 32 vbexclamation 48 vbinformation 64 i vbdefaultbutton1 0 vbdefaultbutton2 256 vbdefaultbutton3 512 vbdefaultbutton4 768

3 VB 67 vbapplicationmodal 0 vbsystemmodal 4096 buttons buttons 0 OK A ALT + MsgBox buttons 7 7 1 7 3.6 3.6 MsgBox vbok 1 OK vbcancel 2 Cancel vbabort 3 Abort vbretry 4 Retry vbignore 5 Ignore vbyes 6 Yes vbno 7 No MsgBox 3.6 3.8.3 VB 1. Chr() ASCII ASCII 0 255 a ASCII 97 Chr(97) a

68 Visual Basic MsgBox " [ ] " 0 " " MsgBox " " 2 " " MsgBox " " 4+32 " " 3.6 MsgBox 2. Val() $ Val("123") 123 3. Ucase() Ucase("abcd") "ABCD" 4. Lcase() Lcase("ABCD") "abcd"

3 VB 69 5. Sqr() Sqr(16) 4 6. Abs() Abs(-100) 100 7. Mid() Mid(string, start[,length]) string NULL NULL start length start start Mid("Computer",1,4) "Comp" 8. Format() Format[$](expr outformat) expr outformat VB 3.7 3.8 3.9 3.7 VB General Number Currency Fixed Standard Percent Scientific 3 2 1 2 3 2 100

70 Visual Basic Yes/No True/False On/Off 0 No Yes 0 False True 0 Off On 3.8 0 0 #. %, 3 E-,E+,e-,e+ : / -,+,$,(,), 3.9 @ & < >! Format(125.25, "00000.000") 00125.250 Format(125.25,"#####.###") 125.25 3.9 3 3.1 VB? 1 XYZ 2 True1 3 False 4 1ABC 5 A[7] 6 Y_1 7 IntA 8 A-2 9 A.3 10 "Comp" 3.2???

3 VB 71 1 name 2 "name" 3 False 4 ff 5 "11 16 99" 6 cj 7 "120" 8 n 9 #11/16/2000# 10 12.345 3.3 VB? 3.4 3 3.7 2 3 2 3 3.7 3.5 123 321 3.8 3.8 3.6 3.9 3.9

72 Visual Basic 3.7 ax 2 bc c 0 3.10 3.10 3.8 3.10 3.11 3.10 20000 20000 29999 30000 599999 60000 5 10 20 40 3.11 3.9 15 3.11 3.12 3.11 15 5 30 9 45 12 60 14 >75 20

3 VB 73 3.12 3.10 Rnd 0 1 1 100 60 3.11 10 A 3.12 3.13 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1... 3.13 3.13 3.14 3.14 3.14 s=1+(1+2)+(1+2+3)+...+(1+2+3+...+n) 3.15 s 1 2 3... n s 4000 n

4 VB VB VB VB 4.1 VB Caption 4.1.1 1 Alignment Object.Alignment[= ] 0 1 2 0( ) 1 2 2 AutoSize Object.AutoSize[=True False] 3 BackStyle Object.BackStyle[= ] 0 1 1( ) 0

4 75 4 BorderStyle Object.BorderStyle[= ] 0 1 0( ) 1 5 Caption Object.Caption[= ] 6 WordWrap Object.WordWrap[=True False] True False 4.1.2 Move Move left,top,width,height left top width height left 4.1.3 Label1 Name Label1 Caption " " BorderStyle 1 BackColor &H00FF8080( ) ForeColor &H000000FF( ) Font _GB2312 4.1 4.2

76 Visual Basic 4.1 4.2 4.2 VB Windows Windows 4.2.1 1 Text Object.Text[= ] 2 MaxLength 0 0 3 MultiLine True False

4 77 Object.MultiLine [=True False] 4 PasswordChar Text MultiLine False 5 ScrollBars Object.ScrollBars[= ] 0 1 2 3 0 1 2 3 MultiLine True 6 SelLength SelStart SelText SelLength / SelStart / SelText / 4.2.2 Change KeyPress SetFocus 1 Change Sub Text_Change([Index As Integer]) Text Index Index 2 KeyPress Sub Text_KeyPress(KeyAscii As Integer) KeyAscii 3 SetFocus 4.2.3 *

78 Visual Basic Name Text1 Appearance 0'Flat BackColor &H00FFFFFF& ForeColor &H000000FF& PasswordChar "*" Text2 Text1 Private Sub Text1_Change() Text2.Text = Text1.Text 4.3 87861654 4.4 4.3 4.4

4 79 4.3 Click VB 4.3.1 1 Cancel Cancel Esc Click Object.Cancel[=True False] True Cancel False Cancel Cancel 2 Caption Object.Captionl[= ] 3 Default Object.Default[=True False] True False 4 Enabled Object.Enabled=True False True False 5 Picture

80 Visual Basic Object.Picture[= ] Style 1 6 Style Object.Style[=0 1] 0 1 Picture 4.3.2 Click DblClick 1 Click Sub Command_Click([Index As Integer]) Command Index Index 2 DblClick Sub Label_DblClick([Index As Integer]) Click 4.3.3 Label1 Command1 Caption " " FontName " " FontSize 14.25 Picture "Form2.frx":0000 Style 1 Command2 Caption " " FontName " " FontSize 14.25

4 81 Private Sub Command1_Click() Label1.Caption = " " Private Sub Command2_Click() Label1.Caption = " " 4.5 command2 4.6 4.5 4.6

82 Visual Basic 4.4 Value Value 0 Value 1 Value 2 0 Click 4.4.1 1 Caption 2 Value 0 1 2 4.4.2 Click Click 4.4.3

4 83 Label1 Check1 Check2 Private Sub Check1_Click() Label1.FontBold = Check1.Value Private Sub Check2_Click() Label1.FontUnderline = Check2.Value 4.7 4.7 4.5 4.5.1 1 Caption Alignment Caption 2 Alignment 0

84 Visual Basic 1 3 Value True False 4.5.2 Click Click 4.5.3 Label1 3 Option1 Option2 Option3 Private Sub Option1_Click() Label1.Caption = " DOS" Private Sub Option2_Click() Label1.Caption = " Windows" Private Sub Option3_Click() Label1.Caption = " Linux" 4.8 4.8

4 85 4.6 4.6.1 Caption Caption 4.6.2 Click Click 4.6.3 Label1 Frame1 3 Option1 Option2 Option3 Private Sub Option1_Click() Label1.Caption = " DOS" Private Sub Option2_Click() Label1.Caption = " Windows" Private Sub Option3_Click() Label1.Caption = " Linux" 4.9

86 Visual Basic 4.9 4.7 6 4.7.1 1 Appearance / 3D 2 AutoRedraw / 3 AutoSize 4 Picture / LoadPicture 4.7.2 6 4.7.3 4.10

4 87 4.10 Picture1 4 Command1 Private Sub Command1_Click(Index As Integer) Select Case Index Case 0 Picture1.Picture = LoadPicture("e:\sf\spring.jpg") Case 1 Picture1.Picture = LoadPicture("e:\sf\summer.jpg") Case 2 Picture1.Picture = LoadPicture("e:\sf\fall.jpg") Case 3 Picture1.Picture = LoadPicture("e:\sf\winter.jpg") End Select 4.8 JPEG GIF 4.8.1 1 Appearance

88 Visual Basic / 3D 2 Picture / LoadPicture 3 Stretch / False True 4.8.2 4.8.3 Stretch 1 Image1 Picture e:\media\ happy.bmp 2 Command1 Command2 Private Sub Command1_Click() ' " " Image1.Width = 1000' Image1.Height = 1000 Image1.Stretch = False Private Sub Command2_Click() ' " " Image1.Width = 1000' Image1.Height = 1000 Image1.Stretch = True 4.11 4.12

4 89 4.11 4.12 4.9 Line 4.9.1 1 BorderColor 2 BorderStyle / 0(Transparent) 1(Solid) 2(Dash) 3(Dot) 4(Dash-Dot) 5(Dash-Dot-Dot) 6(Inside Solid) 3 BorderWidth / 4 X1 Y1 / 5 X2 Y2 /

90 Visual Basic 4.9.2 4.9.3 4.13 4.13 4 4 BorderStyle 3 BorderColor BorderWidth 2 4.10 Shape 4.10.1 BorderColor BorderStyle BorderWidth 4.9 1 FillColor / 2 FillStyle / 3 Shape

4 91 0 1 2 3 4 5 4.10.2 4.10.3 Shape1 Frame1 6 Option1 Shape Private Sub Option1_Click(Index As Integer) Shape1.Shape = Index 'Index Option1 4.14 4.14

92 Visual Basic 4.11 VB 4.11.1 1 MultiSelect 0 1 Space 2 Ctrl Shift 2 ListCount 3 List List List 0 ListCount 1 4 Selected List List List(1) Selected(1) True List(1) Selected(1) False 5 Sorted True False Sorted 6 SelCount MultiSelect 1 2 Selected

4 93 7 Style 0 1 4.15 4.15 4.11.2 1 Click 2 AddItem Object.AddItem Item,Index Item Index Index Item Index Sorted True Item Sorted False Item 3 RemoveItem Object.RemoveItem Index Index 4 Clear Object.Clear

94 Visual Basic 4.11.3 4.16 4.16 Label1 Label2 List1 List2 Command1 Command2 List1 4 MultiSelect 1 Private Sub Command1_Click() n = List1.ListCount - 1 i = 0 Do While i <= n If List1.Selected(i) Then List2.AddItem List1.List(i) List1.RemoveItem i n = n - 1 Else i = i + 1 End If Loop Private Sub Command2_Click() n = List2.ListCount - 1 i = 0 Do While i <= n If List2.Selected(i) Then List1.AddItem List2.List(i) List2.RemoveItem i n = n - 1 Else

4 95 i = i + 1 End If Loop 4.12 4.12.1 1 Style 0 1 2 4.17 4.17

96 Visual Basic 2 Text Style 0 1 Text Style 2 Text Text Text List AddItem RemoveItem 4.12.2 1 Change 2 Click 3 AddItem 4 Clear 5 RemoveItem 4.12.3 Combo1 Label1 List Private Sub Combo1_Change() Label1.Caption = " " + Combo1.Text Private Sub Combo1_Click() Label1.Caption = " " + Combo1.Text

4 97 4.13 ms 1 18 1/18 s 4.13.1 1 Enabled Object.Enabled=True False True Enabled True 2 Interval 0 65 535ms Interval 1000ms 1s 1s 1s n Interval 1000/n 0 4.13.2 Timer Interval 4.13.3 Label1 Label2 Timer1 Interval 100 Private Sub Timer1_Timer() Label2.Caption = Time 4.18

98 Visual Basic 4.18 4.14 Path 4.14.1 1. Drive Object.Drive= Drive1.Drive="c:\" 'Drive Drive ChDrive ChDriveDrive1.Drive 2. Path Object.Path=

4 99 3. 1 Path 2 Pattern 3 Filename 4.14.2 Change Click DblClick 4.14.3 Label1 Drive1 Dir1 File1 Private Sub Dir1_Change() File1.Path = Dir1.Path Label1.Caption = "" Private Sub Drive1_Change() Dir1.Path = Drive1.Drive Label1.Caption = "" Private Sub File1_Click() If Len(Dir1.Path) > 3 Then Label1.Caption = " " + Dir1.Path + "\" + File1.FileName Else Label1.Caption = " " + Dir1.Path + File1.FileName End If 4.19 d d COMPUTER GSWDLL.DLL 4.20

100 Visual Basic 4.19 4.20 4.15 VB 4.21

4 101 4.21 4.15.1 1 Max Min -32 768 32 767 Max 32 767 Min 0 Min Max Min Max 2 Value 3 LargeChange 1 4 SmallChange 1 4.15.2 1 Scroll 2 Change

102 Visual Basic 4.15.3 label1 Text1 VScroll1 Max 100 Min 0 HScroll1 Max 100 Min 0 Private Sub HScroll1_Change() Text1.Text = HScroll1.Value VScroll1.Value = HScroll1.Value Private Sub VScroll1_Change() Text1.Text = VScroll1.Value HScroll1.Value = VScroll1.Value 35 4.22 4.22

4 103 4.16 VB Form1 Label1 Picture1 Frame1 Timer1 Timer2 Command1 Frame1 5 Label2 2 Option1 Combo1 Timer1 Interval 400 Timer2 Label1 Interval 1000 Combo1 4.23 4.23 'n Dim n As Integer Private Sub Form_Load() n = 0 'n Private Sub Command1_Click(Index As Integer) If Index = 0 Then ' Text1(0).SetFocus Else' Text1(0).Text = "" Text1(1).Text = ""

104 Visual Basic Text1(2).Text = "" Combo1.Text = "" Option1(0).Value = Empty End If Private Sub Timer1_Timer() ' e:\vbook 1.bmp 16.bmp ' n = n + 1 If n = 16 Then n = 1 fn = "e:\vbook\" + Trim(Str(n)) + ".bmp" Picture1.Picture = LoadPicture(fn) Private Sub Timer2_Timer() ' Label1.Caption = " :" + Str(Time) 4.24 4.24 VB

4 105 4.17 4 4.1 4.25 4.2 4.26 4.25 4.3 4.27 4.26 4.27 4.4 4.28 4

106 Visual Basic 4.28 4.5 4.29 4 4.29 4.6 4.30 2 4.30

4 107 4.7 4.31 4.31 4.8 4.32 4.32 4.9 4.33 4.33 4.10 4.34

108 Visual Basic 4.34 4.11.bmp 26 4.35 e:\media 26 4.35 4.12 10 4.36 5 4.36

5 VB 5.1 Form VB VB 5.1.1 1 Appearance 3D.Appearance=0 1 0 1 2 AutoRedraw.AutoRedraw[=True False] True False 3 BackColor ForeColor 4 BorderStyle.BorderStyle= 0 5 0 1 2 3 4 5 5 Caption

110 Visual Basic.Caption= 6 FillStyle.FillStyle= 0 7 1 7 Icon 8 MaxButton.MaxButton=True False True False 9 MDIChild MDI.MDIChild=True False True MDI False MDI 10 MinButton.MinButton=True False True False 11 Movable.Movable=True False True False 12 Picture 13 ScaleMode.ScaleMode= 0 7 0 1 2 3 4 5 6 7 14 Visible.Visible=True False

5 111 True False 15 WindowsState.WindowsState= 0 2 0 1 2 5.1.2 VB 1 Activate 2 Click 3 DblClick 4 Deactivate 5 Initialize MDI 6 Load 7 MouseDown 8 QueryUnload 9 Resize 10 Terminate MDI 11 Unload 5.1.3 VB 1 Load VB

112 Visual Basic Load VB Load < > Load Form1 Form1 2 Show.Show 0 1 Show VB 3 Hide Visible False VB.Hide Hide VB 4 Unload Unload 5.1.4 VB VB 4 1. Initialize Form_Initialize

5 113 Form_Initialize Sub Function Property 2. Load Form_Load Form_Load (hwnd) (hdc) Show Form_Load Hide Load Form_Load 3. Form1.Show Form1.Hide ' Form1 ' Form1 Unload QueryUnload QueryUnload QueryUnload QueryUnload Cancel True Unload 4. Nothing Name Nothing Set Form1=Nothing Terminate

114 Visual Basic 5.1.5 (Name) ( ) Index Null 1. 1 ( ) 2 (Y) 2. Index 0 5.1.6 Tab Microsoft Windows ( ) ( ) Frame Lable Menu Line Image Timer

5 115 GotFocus LostFocus GotFocus LostFocus SetFocus Enabled Visible True Enabled Visible Tab Tab Tab Tab 3 Command1 Command2 Command3 Command1 Tab Command2 Command3 Tab Command1 Command3 TabIndex Tab TabIndex Tab TabIndex 0 TabIndex 1 Tab VB Tab Command3 Tab TabIndex TabIndex Tab Tab Tab TabStop False TabStop False Tab Tab 5.1.7 5.1 Name Caption Picture Proj5.1 Form1 Form1 " " "summer.jpg"

116 Visual Basic 5.1 Proj5-1 Form1 5.2 5.1 5.2 5.2 Proj5-1 Form2 BackColor Caption MaxButton = MinButton = &H00FFC0C0& " " 0 'False 0 'False label1 label2 5.3

5 117 5.3 Form2 Private Sub Form_Click() Label2.Caption =" " Private Sub Form_dblClick() Label2.Caption=" " Private Sub Form_Load() Label1.Caption=" " Proj5-1 Form2 5.4 Load label2 5.5 label2 5.4 Form2 (a)

118 Visual Basic 5.5 Form2 (b) 5.2 VB 5.2.1 5.6 5.6

5 119 1. Caption - Name Index 2. 7... 3. Caption

120 Visual Basic 5.2.2 VB Name_Click() Name VB Name_Click() Click 5.2.3 Enabled Visible 5.4 5.2.4 5.3 Proj5-1 Form3 label1 5.7

5 121 5.7 5.8 5.8 Name_Click 5.8 Form3

122 Visual Basic Private Sub menu111_click() Label1.Caption = " " Private Sub menu112_click() Label1.Caption = " " Private Sub menu113_click() Label1.Caption = " " Private Sub menu114_click() Label1.Caption = " " Private Sub menu115_click() Label1.Caption = " " Private Sub menu121_click() Label1.Caption = " " Private Sub menu122_click() Label1.Caption = " " Private Sub menu123_click() Label1.Caption = " " Private Sub menu124_click() Label1.Caption = " " Private Sub menu211_click() Label1.Caption = " " Private Sub menu212_click() Label1.Caption = " "

5 123 Private Sub menu213_click() Label1.Caption = " " Private Sub menu221_click() Label1.Caption = " " Private Sub menu222_click() Label1.Caption = " " Private Sub menu223_click() Label1.Caption = " " Private Sub menu224_click() Label1.Caption = " " Proj5-1 Form3 5.9 5.9 Form3 5.4 Proj5-1 Form4 label1 label2 label3 text1 text2 text3 5.10 Oper... Add... Sub... Mul

124 Visual Basic...- Spbar... Div Exit 5.10 Form4 Private Sub Add_Click() Text3.Text = Val(Text1.Text) + Val(Text2.Text) Private Sub Mul_Click() Text3.Text = Val(Text1.Text) * Val(Text2.Text) Private Sub Oper_Click() If Val(Text2.Text) = 0 Then Div.Enabled = False Else Div.Enabled = True End If Private Sub Sub_Click() Text3.Text = Val(Text1.Text) - Val(Text2.Text) Private Sub Div_Click() Text3.Text = Val(Text1.Text) / Val(Text2.Text) Private Sub Exit_Click() End Proj5-1 Form4 text1 12 text2 5.11 text2 2 5.12

5 125 5.13 5.11 Form4 (a) 5.12 Form4 (b) 5.13 Form4 (c) 5.3

126 Visual Basic 5.3.1 PopupMenu PopupMenu,flags,x,y,boldcommand flags PopupMenu x flags flags 0 x 4 x 8 x flags 0 2 boldcommand PopupMenu Oper 0 Div Oper Div 5.14 Div 5.14 5.3.2 5.5 Proj5-1 Form5 label1 label2 label3 text1 text2 text3 5.15

5 127 5.15 Form5 Oper... Add... Sub... Mul...- Spbar... Div Oper Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single,Y As Single) ' PopupMenu If Button = 2 Then PopupMenu oper, 2 End If Private Sub Add_Click() Text3.Text = Val(Text1.Text) + Val(Text2.Text) Private Sub Mul_Click() Text3.Text = Val(Text1.Text) * Val(Text2.Text) Private Sub Sub_Click() Text3.Text = Val(Text1.Text) - Val(Text2.Text) Private Sub Div_Click() If Val(Text2.Text) <> 0 Then Text3.Text = Val(Text1.Text) / Val(Text2.Text) Else MsgBox " 2 0 ",vbokonly," " End If

128 Visual Basic Proj5-1 Form5 text1 10 text2 15 5.16 5.16 Form 5 5.4 VB MDI Office Office 97 Word 97 Excel 97 VB MDIChild True MDI 5.4.1 MDI MDI 1. MDI 1 MDI 2 3 MDI 4 MDI 5 MDI 6 MDI MDI 7 AutoShowChildren

5 129 2. MDI ActiveForm MDI Arrange MDI 5.4.2 MDI VB Form1 MDI MDI MDI MDIForm1 5.4.3 MDI MDI 1. MDI VB Form1 MDI Form1 MDI MDIChild True 2. MDI MDI MDIChild True MDIChild MDI 5.4.4 MDI 1. MDI MDI Load MDI Form1 Form2 Private Sub MDIForm1_Load Form1.Show Form2.Show

130 Visual Basic 2. MDI MDI UnloadMDI Unload Me QueryUnload MDI 5.4.5 MDI 5.6 proj5-2 MDI MDIForm1 5.17 4 menu1 menu2 menu3 menu4 5.17 MDI MDI Form1 Form2 MDI MDI MDI MDIForm1 Private Sub MDIForm_Load() Form1.Show Form2.Show Private Sub menu1_click()

5 131 MDIForm1.Arrange vbcascade Private Sub menu2_click() MDIForm1.Arrange vbtilehorizontal Private Sub menu3_click() MDIForm1.Arrange vbarangeicons Private Sub menu4_click() Unload Me MDIForm1 5.18 5.19 5.18 MDIForm1 5.19

132 Visual Basic 5.7 MDI proj5-3 MDI MDIForm1 Picture1 5, 5.20 Picture1 Align 1 'Top Command1 Caption " " Command2 Caption " " Command3 Caption " " Command4 Caption " " Command5 Caption " " Label1 AutoSize -1 'True 5.20 MDIForm1 MDI Form1 Proj5-1 Form3 MDIForm1 Dim i As Integer Private Sub command1_click() i = i + 1 Dim NewDoc As New Form1 NewDoc.Caption = " " + Str(i) + " " NewDoc.Show Label1.Caption = Str(Forms.Count - 1) + " " Private Sub command2_click() MDIForm1.Arrange vbcascade

5 133 Private Sub command3_click() MDIForm1.Arrange vbtilehorizontal Private Sub command4_click() MDIForm1.Arrange vbarrangeicons Private Sub Command5_Click() Unload Me Private Sub Command6_Click() Label1.Caption = Str(MDIForm1.Count) MDIForm1 MDI 4 MDI 5.21 MDI 5.21 MDI Form1 5.5 5 5.1 5.22 5.2 5.23

134 Visual Basic 5.22 5.23 5.3 5.4 text2 0 5.4 5.24 5.24

6 Windows GUI Windows VB 6.1 VB 6.1.1 VB.bmp.dib.ico.cur.wmf.emf.jpg.gif Bitmap ( ).bmp.dib 2 4 8 16 24 32 8 256 4 16 16 Icon 32 32 Windows 95 16 16.ico Metafile.wmf.emf JPEG 8 24 Internet GIF CompuServe 256 Internet 1. VB Image PictureBox

136 Visual Basic Image Image( ) Picture Picture LoadPicture() Picture GetData Picture PictureBox Image Print MDI( ) MDI ( ) 2. 1 Picture Picture VB Windows95 VB 2 LoadPicture LoadPicure Picture objectname.picture=loadpicture("[filename]") objectname Name Filename filename ("") Picture picdisplay imgdisplay imgdisplay.picture=picdisplay.picture Picture

6 137 objectname.picture=clipboard.getdata([format%]) 6.1 Form1 Picture1 Image1 File1 Picture1 AutoSize True Appearance 0-Flat Image1 Stretch True File1 Path e:\media Pattern *.bmp;*.ico;*.cur;*.jpg Dim filepath As String Private Sub File1_Click() Picture1.Picture = LoadPicture(filepath + "\" + File1.FileName) Image1.Picture = Picture1.Picture Form1.Picture = Picture1.Picture Private Sub Form_Load() filepath = "e:\media" File1.Path = filepath Form1 6.1 HAPPY.BMP 6.1 Form1 File1_Click() LoadPicture() Picture

138 Visual Basic AutoSize True 1 2 AutoSize AutoSize ( ) AutoSize True AutoSize True 3 Stretch True Stretch False 6.1.2 ( ) 1. Line BorderCo1or QColor() RGB() BorderStyle BorderWidth 6.2 2. Line Circle

6 139 Shape FillColor FillStyle Form2 6.2 4 4 command1 Private Sub Command1_Click() Text4.Text = Text1.Text * Text2.Text * Text3.Text 6.2 Form2 Form2 5 6 4 120 6.3 6.3

140 Visual Basic 6.2 VB 6.1 6.1 Cls Pset Point Line Circle PaintPicture Print Print Set Line Circle ( AutoRedraw ) 6.2.1

6 141 1. ( ) 640 480 800 600 1024 768 VB 7 (0 0) twips Screen( ) VB 8 6.2 twips ( ) ScaleMode 6.2 VB ScaleMode 0 ScaleWidth ScaleHeight ScaleTop ScaleLeft VB ScaleMode 0 1 twips 144twips 2 1 72 3 4 =120twips =240twips 5 6 7 2. 6.3 6.3 CurrentX CurrentY Height Width ScaleHeight ScaleWidth Left Top ScaleLeft ScaleTop ( ) (0 0)

142 Visual Basic ( ) 1 ScaleLeft ScaleTop ScaleHeight ScaleWidth ScaleLeft ScaleTop ScaleHeight ScaleWidth Form1 (10 20) (60 50) Form1.ScaleWidth=50 Form1.ScaleHeight=30 Form1.ScaleTop=20 Form1.ScaleLeft=10 0 0 6.4 0 0 20 10 30 50 6.4 (ScaleLeft ScaleTop) (ScaleLeft+ScaleWidth ScaleTop+ScaleHeight) (ScaleLeft ScaleTop+ScaleHeight) (ScaleLeft+ScaleWidth ScaleTop) (50 100) ScaleLeft=20 ScaleTop=100 ScaleWidth=50 ScaleHeight=-100

6 143 Picture1 6.5 Private Sub Form_Load() Picture1.ScaleLeft=-15 Picture1.ScaleTop=-25 Picture1.ScaleWidth=30 Picture1.ScaleHeight=50 (-15,-25) (15,-25) (0 0) X (-15,25) (15,25) Y 6.5 2 Scale Scale ScaleTop ScaleLeft ScaleWidth ScaleHeight Scale [formname] [pictureboxname].scale[(x1 y1)-(x2 y2)] (x1 y1) (x2 y2) x1=scaleleft;y1=scaletop;x2=scalewidth+x1;y2=scaleheight+y1 Scale (0 0) 2 15 0.5 1.5 Scale Scale(0 2)-(20 0) 6.2.2 VB 1. PSet PSet

144 Visual Basic DrawWidth PSet [formname] pictureboxname.pset[step](x,y)[,color] (x y) color Long ForeColor color QBColor() RGB() Step ( ) (x,y) 6.3 Form3 Dim mouse As Boolean ' Private Sub Form_Load() mouse = False Me.DrawWidth = 2 ' ( ) Me.ForeColor = vbred ' Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) mouse = True Me.PSet (X, Y) Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If mouse Then Me.PSet (X, Y) Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) mouse = False Form3 Form3 6.6 PSet 6.6 Form3

6 145 2. Line Line ( ) 1 Line objectname.line [[Step](x1,y1)]-[Step](x2,y2)[,color] Step (x1,y1) Step (x1,y1) (x1,y1) (0,0) (x1,y1) (CurrentX,CurrentY) (x2,y2) Step (x2,y2) (x1,y1) (x2,y2) color ForeColor DrawWidth DrawStyle 6.4 6.4 DrawStyle vbsolid 0 vbdash 1 vbdot 2 vbdashdot 3 vbdashdotdot 4 vbinvisible 5 vbinsidesolid 6 6.4 Form4 Const pi = 3.14159 Private Sub star(x As Single) Randomize n = Int(Rnd * 16) colr = QBColor(n) Line -Step(x * Sin(pi / 10), -x * Cos(pi / 10)), colr Line -Step(x * Sin(pi / 10), x * Cos(pi / 10)), colr Line -Step(-x * Cos(2 * pi / 10), -x * Sin(2 * pi / 10)), colr Line -Step(x, 0), colr Line -Step(-x * Cos(2 * pi / 10), x * Sin(2 * pi / 10)), colr

146 Visual Basic Private Sub Form_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single) PSet (x, y) star (Rnd * 2000) star 2 /10 Rnd Randomize Form4 Form4 6.7 6.7 Form4 6.5 Sin x Cos x Sin x Cos x Form5 Picture1 Appearance 0 BackColor 6.5 menu 6.5 menu popmenu...sin x hs 0...Cos x hs 1... hs 2 Const pi = 3.14159 Private Sub Form_paint() With Picture1

6 147.Height = Me.ScaleHeight.ScaleMode = 6 oldx =.ScaleWidth / 2 oldy =.ScaleHeight / 2.Cls ' Picture1.Line (oldx,.top)-(oldx,.scaleheight), RGB(255, 0, 0) Picture1.Line (0, oldy)-(.scalewidth, oldy), RGB(255, 0, 0) End With Picture1.CurrentX = oldx - 4 Picture1.CurrentY = oldy + 0.5 ' Picture1.Print 0 For xt = -Int(oldx) To Int(oldx) Step 0.5 If xt <> 0 Then st = xt * 10 * pi Picture1.CurrentX = oldx + st - 3 Picture1.CurrentY = oldy + 0.5 ' x Picture1.Print xt & " " Picture1.Line (oldx + st, oldy - 1)-(oldx + st, oldy), RGB(255, 0, 0) End If Next xt For yt = -5 To 7 If yt <> 0 Then st = yt * 10 Picture1.CurrentX = oldx - 4 Picture1.CurrentY = oldy + st - 1 ' y Picture1.Print yt Picture1.Line (oldx, oldy + st)-(oldx + 1, oldy + st), RGB(255, 0, 0) End If Next yt Label1.Caption = "" Private Sub Form_Resize() Form_paint

148 Visual Basic Private Sub hs_click(index As Integer) oldx = Picture1.ScaleWidth / 2 oldy = Picture1.ScaleHeight / 2 Select Case Index Case 0 Label1.Caption = "Sin(x) " For t = -oldx To oldx Step 0.01 xt = 10 * t yt = 10 * Sin(t) Picture1.PSet (xt + oldx, oldy - yt), RGB(0, 127, 127) Next Case 1 Label1.Caption = "Cos(x) " For t = -oldx To oldx Step 0.01 xt = 10 * t yt = 10 * Cos(t) Picture1.PSet (xt + oldx, oldy - yt), RGB(0, 127, 127) Next Case 2 Picture1.Cls Form_paint Exit Sub End Select Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 2 Then PopupMenu popmenu, 6 End If Form5 Form5 6.8 Sin x 6.9 Sin x 6.8 Form5 (1)

6 149 6.9 Form5 2 2 Line Line Line B F Line objectname.line[[step](x1,y1)]-[step](x2 y2)[,color],[b[,f]] Step (x1,y1) Step Step (CurrentX,CurrentY) (x2,y2) Step Step (x1,y1) (x1,y1) (CurrentX CurrentY) color ( ) ForeColor B Line ( ) F B ( B ) FillStyle Circle 6.6

150 Visual Basic 6.6 FillStyle vbfssolid 0 vbfstransparent 1 ( ) vbhorizontalline 2 vbverticalline 3 vbupwarddiagonal 4 vbdownwarddiagonal 5 vbcross 6 vbdiagonalcross 7 FillStyle 1( ) FillColor Form FillColor DrawWidth DrawStyle 3. Circle Circle DrawWidth DrawStyle FillColor FillStyle Circle 1 Circle objectname.circle [Step](x,y),radius[,color] (x,y) Step (x,y) (CurrentX,CurrentY) Step (x,y) radius color ForeColor FillColor ( ) FillStyle ( ) 6.6 Form6 Private Sub Form_Load() Show Dim X, Y, r, r1, i Randomize ScaleMode = 6 ' mm

6 151 DrawWidth = 2 ' 2 X = ScaleWidth / 2 ' r Y = ScaleHeight / 2 If ScaleWidth > ScaleHeight Then r = Y Else r = X End If For r1 = 0 To r ' r1 Circle (X, Y), r1, RGB(255 * Rnd, 255 * Rnd, 255 * Rnd) Next Form6 6.10 6.10 Form6 2 Circle 1:1 objectname.circle[step](x,y),radius[,color],,,aspect aspect 1 ( ) 1 1 aspect 6.7 6.11 Form7 Private Sub Form_Load() Show Scale (-15, 14)-(15, -14) Circle (0, 0), 7 Circle (0, 0), 7,,,, 2.5 ' ' '

152 Visual Basic FillStyle = 7 Circle (0, 0), 7, RGB(255, 0, 0),,, 0.4 ' 6.11 Form7 3 Circle objectname.circle [Step](x,y),radius[,color][start,end][,aspect] start end 0 2 start end start end start end start end 0 /2 0 /2 0 /2 0 - /2 3 /2 0 6.8 6.12 Form8 Const pi = 3.14159 Private Sub Form_Load() Show ForeColor = vbred DrawWidth = 2 Circle (1800, 500), 1000,, -pi, -1.5 * pi ' Circle (3500, 500), 1000,, pi, 1.5 * pi '

6 153 6.12 Form8 6.9 Form9 Picture1 Frame1 Picture1 Appearance 0 Label1 Label2 Label3 Text1 Text2 Text3 Command1 Const pi = 3.14159 Private Sub Command1_Click() Dim a As Single Dim b As Single Dim c As Single Dim s As Single a = Val(Text1.Text) b = Val(Text2.Text) c = Val(Text3.Text) s = a + b + c If s = 0 Then MsgBox " ", vbokonly, " " Exit Sub End If a = a / s b = b / s Call hb(a, b) Private Sub hb(a As Single, b As Single) Picture1.FillStyle = 0 For i = 0 To 200 Picture1.FillColor = vbred ' Picture1.Circle (1500, 1500 - i), 1000, vbred, -2 * pi, -2 * pi * a, 2 / 3

154 Visual Basic Picture1.FillColor = vbgreen ' Picture1.Circle (1500, 1500 - i), 1000, vbgreen, -2 * pi * a,-2 * pi * (a + b), 2 / 3 Picture1.FillColor = vbblue' Picture1.Circle (1500, 1500 - i), 1000, vbblue, -2 * pi * (a + b),-2 * pi,2 / 3 Next Picture1.FillColor = vbred ' Picture1.Circle (1500, 1500 - i), 1000, vbwhite, -2 * pi, -2 * pi * a, 2 / 3 Picture1.FillColor = vbgreen ' Picture1.Circle (1500, 1500 - i), 1000, vbwhite, -2 * pi * a,-2 * pi * (a + b), 2 / 3 Picture1.FillColor = vbblue ' Picture1.Circle (1500, 1500 - i), 1000, vbwhite, -2 * pi * (a + b),-2 * pi, 2 / 3 Command1_Click hb hb 200 For...Next 200 Form9 Form9 32 40 35 6.13 6.13 Form9 6.3

6 155 6.3.1 AutoRedraw True Paint AutoRedraw Paint 1. AutoRedraw ( ) -1(True) 0(False) AutoRedraw True PictureBox AutoRedraw False 2. Paint Paint Circle Line AutoRedraw Paint AutoRedraw AutoRedraw False Paint AutoRedraw Paint AutoRedraw AutoRedraw AutoRedraw AutoRedraw True Paint Paint 6.10 AutoRedraw Paint Form10 Form11 Form10 Command1 Private Sub Command1_Click()

156 Visual Basic Form11.Show Form11 Private Sub Form_Click() Me.Scale (0, 0)-(18, 8) Me.AutoRedraw = True Me.DrawWidth = 2 Circle (3, 4), 3, vbred ' Me.AutoRedraw = False Line (7, 1)-Step(4, 6), vbgreen, B ' Line (13, 7)-Step(4, 0), vbblue ' Line Step(0, 0)-Step(-2, -6), vbblue Line Step(0, 0)-Step(-2, 6), vbblue Private Sub Form_Paint() Line (7, 1)-Step(4, 6), vbgreen, B ' Form11 Form_Click() AutoRedraw True AutoRedraw False Form_Paint() Form10 Form10 Form11 Form11 Form11 Form_Click 6.14 Form10 Form10 Form11 Form11 Form11 6.15 6.14 Form11

6 157 6.15 Form11 Form11 AutoRedraw True Form11 AutoRedraw False Form_Paint AutoRedraw Paint 6.3.2 PaintPicture Printer Picture LoadPicture object.paintpicture pic,dx,dy,dw,dh,sx,sy,sw,sh,opcode object object pic object Picture dx,dy dw,dh sx,sy sw,sh

158 Visual Basic opcode PaintPicture Opcode ScaleMode AutoRedraw ScaleMode AutoRedraw True PaintPicture PaintPicture 6.11 PaintPicture Form12 Picture1 Picture2 Command1 Command2 Picture1 Picture Beany.cur Picture2 AutoRedraw True Private Sub command1_click() ' Dim sw, sh, sx, sy As Integer sw = Picture1.ScaleWidth sh = Picture1.ScaleHeight sx = sw sy = 0 Picture2.Picture = LoadPicture("") ' Picture2.PaintPicture Picture1.Picture, 0, 0, sw, sh, sx, sy, -sw, sh Private Sub Command2_Click() ' Dim sw, sh, sx, sy, dw, dh As Integer sw = Picture1.ScaleWidth sh = Picture1.ScaleHeight dw = 1.5 * sw dh = 1.5 * sh sx = 0 sy = sh Picture2.Picture = LoadPicture("") ' Picture2.PaintPicture Picture1.Picture, 0, 0, dw, dh, sx, sy, sw, -sh Form12 Form12 6.16 Picture2

6 159 6.17 Picture2 6.16 6.3.3 6.17 Picture GIF JPEG SavePicture SavePicture pic,fn pic fn 6.12 SavePicture Form13 Picture1

160 Visual Basic Command1 Picture Winter.jgp Private Sub Command1_Click() SavePicture Picture1.Image, "e:\media\abc.bmp" Picture1 e:\media\abc.bmp 6.4 6 6.1 VB 6.18 6.18 6.2 VB 6.18 6.3 VB 6.19 6.19 6.4 VB 6.20

6 161 6.20 6.5 6.21 Cos(2x)Sin(5x) 6.21 6.6 6.22 180 6.22

7 7.1 VB 7.1.1 ASCII 7.1 7.1.C 7.1.2 7.2

7 163 n n+1 n n+1 7.2 7.1.3 ( ) 7.2 ASCII 7.2.1 Open Open [For [Access ][Lock]As[#] [Len= ] Output Input Append Read

164 Visual Basic Write ReadWrite Append Lock Shared LockRead LockWrite 1 255 FreeFile() 32 767 7.2.2 Output Output Append Append VB Print #, 1[;][","][; 2[;][","] Write #, 1[, 2] Print Write try.txt txtmytext FileNum=FreeFile() Open "try.txt" For 0utput As FileNum Print #FileNum,txtMyText.Text Close FileNum 7.2.3 Input Input #, 1[, 2]{, }, Line Input #, Input$ ( # )

7 165 try.txt txtourtext FileNum=FreeFile() 0pen try.txt For Input As FileNum txtourtext.text=input$(lof(filenum),filenum) Close 7.2.4 Close [# 1][ # 2] Close 7.2.5 ( ) 1. LOF() LOF( ) LOF 1 #1 2. LOC() LOC( ) 128 128 3. EOF() EOF( ) True False

166 Visual Basic 7.1 Form1 txt MultiLine True Command1 Command2 7.3 Private Sub Command1_Click() ' fno = FreeFile Open "File.dat" For Output As #fno Print #fno, txt.text Close #fno 7.3 Form1 Private Sub Command2_Click() ' txt.text = "" fno = FreeFile Open "File.dat" For Input As #fno Do Until EOF(fno) Line Input #fno, newline txt.text = txt.text & newline & Chr(13) + Chr(10) Loop Close #fno Form1 File.dat 7.4

7 167 7.4 Form1 7.3 7.3.1 Open For Random As # [Len= ] Open 128 7.3.2 Put Put [#],[ ], # 1

168 Visual Basic Put #1,student student #1 7.3.3 Get Get [#],[ ], 1 Get #1,1,student 1 student 7.3.4 Put 1 5 Positlon 6 LastRecord = LastRecord + l Put #FileNum, LastRecord Employee 7.3.5 1 N : 'recordnum i=n DO While i<=recordnum Get #1,i+1,recvar Put #,i,recvar i=i+1 Loop ' i recordnum=recordnum-1

7 169 7.3.6 Kill Name 7.2 Form2 4 4 Text1 4 Command1 Command2 7.5 7.5 Form2 ' stud.dat Private Type StudType No As String * 4 Name As String * 10 Age As Integer Class As String * 5 End Type Dim Stud As StudType Dim Recnum As Integer Private Sub Form_Load() For i = 0 To 3 Text1(i).Text = "" Next Private Sub Command1_Click(Index As Integer) On Error Resume Next Recnum = InputBox(" ", " ") If Recnum = 0 Then Exit Sub Open "stud.dat" For Random As #1 Len = Len(Stud)

170 Visual Basic If Index = 0 Then totalrec = LOF 1 / Len(Stud) ' For i = totalrec To Recnum Step -1 Get #1, i, Stud Put #1, i + 1, Stud Next Stud.No = Text1(0).Text Stud.Name = Text1(1).Text Stud.Age = Text1(2).Text Stud.Class = Text1(3).Text Put #1, Recnum, Stud End If If Index = 1 Then totalrec = LOF 1 / Len(Stud) ' For i = Recnum To totalrec - 1 Get #1, i + 1, Stud Put #1, i, Stud Next Stud.No = "" Stud.Name = "" Stud.Age = Empty Stud.Class = "" Put #1, i, Stud End If If Index = 2 Then Get #1, Recnum, Stud Text1(0).Text = Stud.No Text1(1).Text = Stud.Name Text1(2).Text = Stud.Age Text1(3).Text = Stud.Class End If Close Private Sub Command2_Click(Index As Integer) End 7.4

7 171 7.4.1 Open For Binary As # Open Open Len Open 7.4.2 Put #,[ ], Put 7.4.3 Get #,[ ], Seek Seek Seek() Seek( ) Seek Seek(,recnumber) recnumber 7.4.4 Person1 Type Person1 ID As Integer Salary As Currency LastReviewDate As Long FirstName As String*15 LastName As String*15

172 Visual Basic Title As String*15 ReviewComments As String*150 End Type 209 Type Person2 ID As Integer Salary As Currency LastReviewDate As Long FirstName As String LastName As String Title As String ReviewComments As String End Type Person2 7.3 Form3 Text1 4 Command1 Command2 Command3 Command4 7.6 Dim mystring As String Private Sub Command1_Click() mystring = String$(10, " ") Get #1, 1, mystring Text1.Text = mystring 7.6 Form3

7 173 Private Sub Command2_Click() mystring = String$(26, " ") Get #1, 11, mystring Text1.Text = mystring Private Sub Command3_Click() mystring = String$(26, " ") Get #1, 37, mystring Text1.Text = mystring Private Sub Command4_Click() Close #1 End Private Sub Form_Load() Open "try.dat" For Binary As #1 mystring = "1234567890" Put #1, 1, mystring mystring = "abcedfghijklmnopqrstuvwxyz" Put #1,, mystring mystring = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" Put #1,, mystring Form3 Form3 try.dat 7.7 7.7 Form3