untitled

Size: px
Start display at page:

Download "untitled"

Transcription

1 Visual Basic

2 Visual Basic 7 Visual Basic Visual Basic CIP Visual Basic/ ISBN BASIC. TP CIP ISBN /TP

3

4 2002 B Windows C QBasic FoxBASE+ Fortran Visual Basic Visual FoxPro PC

5 Visual Basic Fortran IV

6 DOS Windows OS/2 Macintosh Unix Linux PC 12 CD-ROM ( [email protected]) Visual Basic / %

7 Visual Basic

8 1 Visual Basic Visual Basic Visual Basic

9 Visual Basic Visual Basic Visual Basic VIII

10 Sub Function Visual Basic IX

11 Visual Basic A B X

12 C D E F XI

13 1 Visual Basic 1 Visual Basic 2 Visual Basic Visual Basic Visual Basic Microsoft MS-Windows BASIC BASIC Windows API DLL DDEOLE ODBC Visual Basic 1.0 Microsoft DOS MS-Windows 3.x MS-Windows 9x/NT/ Microsoft Visual Basic Visual Basic Visual Basic 6.0 Microsoft Microsoft Visual Studio Visual Basic Windows Tab ActiveX Internet Crystal Report Writer

14 Visual Basic / Internet/Intranet Microsoft Visual Source Safe Visual Basic 1. Visual Basic Visual Basic 2. Visual Basic 4.0 OOP Visual Basic 3. Visual Basic Visual Basic Visual Basic 4. Visual Basic Visual Basic 5. Visual Basic MS-Access.mdb dbase FoxPro Paradox ODBC SQL Server Oracle SQL Visual Basic ActiveX ADO RDO Visual Basic 2

15 1 Visual Basic Visual Basic 1 2 Visual Basic Visual Basic Visual Basic 1 2 MS-Windows Visual Basic Microsoft MS-Windows Visual Basic 1 Microsoft 2 3 Visual Basic 1 MS-Access dbase FoxPro Paradox 2 SQL Server Oracle / MS-Access dbase FoxPro Visual Basic / SQL Server Oracle Visual Basic ODBC 1 2 ODBC 4 A Visual Basic B C++ C Java D Pascal Visual Basic C++ Java Pascal 3

16 Visual Basic D 5 4 A B C D D 6 GUI A C B D GUI Graphical User Interface B Visual Basic 6.0 Microsoft Visual Basic 6.0 Microsoft Visual Basic 6.0 Microsoft Visual Basic 6.0 Visual Basic 6.0 Visual Basic vb60 vb6.exe Visual Basic 1-1 EXE Visual Basic IDE 1-2 Visual Basic MDI 1-2 SDI Visual Basic Visual Basic Visual Basic 4

17 1 Visual Basic Visual Basic IDE Visual Basic Alt+Q Windows 5

18 Visual Basic Visual Basic SDI Visual Basic MDI SDI Multiple Document Interface MDI MDI 2 Visual Basic Visual Basic A Alt+Q B Del C Ctrl+Q D Ctrl+P Del Ctrl+P Ctrl+Q Alt+Q Visual Basic A Visual Basic

19 1 Visual Basic 1-Microsft Visual Basic 1 Visual Basic 3 Windows Word 13 / MS-Office 1 2 N Ctrl+N Ctrl N 3 F10 Alt 4 F10 Alt F 5<Alt+ > <Alt+F> 7

20 Visual Basic 6 Esc Alt 2. Visual Basic / twip 1 inch=1440 twip Microsft Visual Basic 8

21 1 Visual Basic 1 2 Visual Basic Visual Basic Standard EXE Visual Basic Visual Basic Esc 2 Alt 5 Visual Basic A F1 C F9 B F5 D F10 F1 F5 F9 F10 D 6 Visual Basic A B C D Visual Basic 3 Visual Basic D 9

22 Visual Basic Visual Basic Form / Name 1.vbp 2.vbg 3.frm 10

23 1 Visual Basic 4.bas 5.cls 6.res

24 Visual Basic Visual Basic 1 2 Visual Basic Visual Basic Visual Basic A Ctrl+D B Ctrl+E C Ctrl+F D Ctrl+G Ctrl+D Ctrl+E Ctrl+F Ctrl+G D 4 A B C Ctrl+T D F4 Ctrl+T Visual Basic C 5 / A Ctrl+T B Shift+F4 12

25 1 Visual Basic C Ctrl+J D F4 Ctrl+T Visual Basic Shift+F4 Ctrl+J / F4 D 1.5 Visual Basic Microsoft MS-Windows 1 Visual Basic 2 Visual Basic 3 Visual Basic IDE Visual Basic A B C D 2 MSDN A Help B F10 C Esc D F1 3 ODBC A B C D 4 A Alt+Q B Shift+F4 13

26 Visual Basic C F4 D Ctrl+R 5 A F4 B Alt+Q C Shift+F4 D Ctrl+R 6 Dim vb vb="visual Basic 6.0" Debug. Print vb A True B False C Visual Basic 6.0 D "Visual Basic 6.0" 7 A inch B twip C cm D pixel 8 API A B C D 9 Visual Basic A B C D 10 Visual Basic A B C D 11 A F2 B Ctrl+F2 C F4 D Ctrl+F4 12 Visual Basic A ADO B DAO C DRO D RDO 13 4 A B C D 1 Visual Basic

27 1 Visual Basic 2 Visual Basic Visual Basic 6.0 ActiveX 5 Visual Basic 6 Visual Basic 7 Visual Basic Microsft Visual Basic 9 Visual Basic

28 2 Visual Basic Visual Basic Visual Basic Visual Basic F4 4 5 <Ctrl+PgDn> <Ctrl+PgUp>

29 2 Visual Basic 3 Caption Text Enable Alt+ Visual Basic print. 2. Windows 1 AutoRedraw True False BackColor ForeColor & BorderStyle 0-None 1-Fixed Single 2-Sizeable 3-Fixed Dialog 4-Fixed Tool Window 5-Sizeable ToolWindow 2 17

30 Visual Basic Caption ControlBox True False BorderStyle 0-None ControlBox True Enabled True False Font Height Width twip Icon.ICO MaxButton MinButton True False BorderStyle 0-None Name Visual Basic Picture Top Left Top Left Visible True False WindowState Click DbClick Load UnLoad Activate Deactivate 18

31 2 Visual Basic Paint AutoRedraw True( 1) 3. Visual Basic 3 ActiveX OLE ActiveX Name Form1 Text1 Command Ctrl

32 Visual Basic

33 2 Visual Basic Width Height Top Left twip Top Left Visual Basic Del 2 1 Shift 8 Shift

34 Visual Basic 5. Visual Basic Visual Basic 1 Paint AutoDraw True( 1) Resize 2 GotFocus LostFocus 3 Click DbClick MouseDown MouseUp MouseMove DragDrop DragOver 4 KeyDown KeyUp KeyPress 5 Change DropDown PathChange 6 Timer Visual Basic 1 2 Visual Basic 22

35 2 Visual Basic Visual Basic Visual Basic ActiveX 3 ActiveX 1 ActiveX Name 1 Visual Basic Name Name Form1 Name Text4 N Name CommandN Command1 4 A B ActiveX C D OLE OLE B 5 Visual Basic A Show B Hide C Load D UnLoand Show Hide Load UnLoad B 6 Visual Basic 23

36 Visual Basic A Name C Text B Caption D Enabled Name Caption Text Enabled A 7 A DragDrop B MouseDown C DbClick D Change DragDrop MouseDown DbClick Change D 8 Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button=2 Then Print "AAAAA" End If Private Sub Form_MouseUp(Button As Integer,Shift As Integer,X As Single,Y As Single) Print "BBBBB" A AAAAA B BBBBB BBBBB AAAAA BBBBB BBBBB C AAAAA D BBBBB BBBBB BBBBB MouseDown MouseUp MouseDown MouseUp Button Button 1 Button 2 Form_MouseDown Button 2 IF AAAAA Form_MouseUp 24

37 2 Visual Basic BBBBB Button 1 IF BBBBB A 9 Option Base 1 Private Sub Form_KeyPress(KeyAscii As Integer) a = Array(237, 126, 87, 48, 498) t1 = a(1) t2 = 1 If KeyAscii = 13 Then For i = 2 To 5 If a(i) > t1 Then t1 = a(i) t2 = i End If Next i End If Print t1 Print t2 A 48 B 237 C 498 D Option Base 1 1 KeyAscii = KeyAscii = 13 a t1 t2 IF KeyAscii = 13 For a(2) a(3) a(4) a(5) t1 t1 t2 a() t1 t2 t1 t2 C

38 Visual Basic A F4 B Ctrl+PgDn C F5 D Ctrl+PgUp 2 Visible A True B False C 0 D 1 3 Visual Basic A Name B Caption C Text D Enabled 4 A Name B Visible C Text D Caption 5 A AutoRedraw B Enabled C MaxButton D BorderStyle 6 A Deactivate B Activate C Load D Click 7 A B C ActiveX D OLE 8 A DragOver B Change C DbClick D MouseDown 9 A B C D 10 Visual Basic A Show B Hide C Load D Unload 11 A Contro1Box False B Contro1Box True BorderStyle 1~5 C Contro1Box False BorderStyle 0 D Contro1Box True BoderStyle 0 26

39 2 Visual Basic 12 Visual Basic A Show B Load C Hide D Unload 13 A Unload B OnFocus C GetFocus D QueryUnload 14 Visual Basic A B ActiveX C D 15 Visual Basic A Shift+Ctrl B Shift+ C Ctrl+ D Ctrl+ 16 A Load B Unload C Resize D Paint 17 a=1:b=2:c=3 a=b:b=c:c=a Print a;b;c A B C D Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 1 Then Print "****" Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) Print "####" 27

40 Visual Basic A **** B #### C **** D #### #### **** **** #### **** #### #### **** 19 Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) FillColor = QBColor(Int(Rnd * 15)) FillStyle = Int(Rnd * 8) Circle (X, Y), 250 A B C D 20 A DragDrop C DbClick B MouseDown D DropDown Visual Basic Dim Msg As Integer Form1. 1 MsgBox "Form1 " Form

41 2 Visual Basic Caption Name Font Height Width Left Top Visible Enabled Alignment AutoSize True BorderStyle 0 1 BackStyle 0 1 WordWrap AutoSize True WordWrap True WordWrap False 29

42 Visual Basic Click DbClick 2 MaxLength MultiLine False True PasswordChar * ScrollBars MultiLine True ScrollBars Text SelText SelLength SelStart 0 1 Locked True Click DbClick Change GotFocus LostFocus SetFocus Change Text GotFocus LostFocus SetFocus

43 2 Visual Basic Print Name Enabled Visible Font AutoRedraw Top Left Height Width Picture none Visual Basic BitmapIconMetafile( ) JPEG GIF CurrentX CurrentY Stretch False Click DbClick Cls Print 2 1 Picture 31

44 Visual Basic Picture Picture 2 Windows.Picture=LoadPicture(" ") Name Visible Height Width Top Left BorderColor BorderStyle 0~ ~6 0 1 Solid 2 Dash 3 Dot 4 Dash-Dot 5 Dash-Dot-Dot 6 Inside Solid 7 Transparent 2-9 BorderStyle BorderWidth BorderStyle 6 32

45 2 Visual Basic BackStyle 0 1 BackColor FillStyle 0 Solid 1 Transparent 2 Horizontal Line 3 Vertical Line 4 Upward Diagonal 5 Downward Diagnoal 6 Cross 7 Diagnoal Cross FillColor FillStyle Shape ~5 0 Rectangle 1 Square 2 Oval 3 Circle 4 Rounded Rectangle 5 Rounded Square 2-10 Shape X1 Y1 X2 Y2 X1 Y1 X2 Y2 33

46 Visual Basic Caption Name Enable Visible Font Height Width Top Left 2-11 Cancel True Esc Cancel True Default True Default True Style 0 1 Picture Style 1 DownPicture Style 1 Picture DisablePicture Enabled False Style 1 Click DbClick 4. Visual Basic

47 2 Visual Basic 2-13 Value True False Alignment 0 1 Style Picture DownPicture DisablePicture 35

48 Visual Basic 2-14 Click Click Click Columns Columns List 0 n n 1 ListCount 36

49 2 Visual Basic ListIndex List 0 n n 1 1 MultiSelect 0-None 1-Simple 2-Extended Shift Ctrl ListIndex Text Selected List True False SelCount Sorted True False Style 0 1 Text AddItem.AddItem [, ] 0 Clear.RemoveItem.Clear RemoveItem.RemoveItem Click DbClick Click DbClick Text 37

50 Visual Basic Style Style=0 Style=1 Style= Text Text Text Click DropDown Change Click DbClick Change Click DropDown AddItem RemoveItem Clear

51 2 Visual Basic Min Max Min Max Min Max Min Max Value Min Max SmallChange Value LargeChange Value Scroll Change Scroll Value Change

52 Visual Basic Visual Basic Enable True True False Interval 1/ Interval Timer Timer Enable False

53 2 Visual Basic Ctrl Caption Click DbClick 8. Tab SetFocus GetFocus LostFocus Enable Visible True Form_Load Show Tab Tab Tab Tab Tab Tab Tab TabStop TabIndex TabStop False Tab TabStop True TabStop False TabIndex Tab TabIndex TabIndex Tab Tab Tab Tab Tab Tab Tab 41

54 Visual Basic Visual Basic Print A Alignment B BorderStyle C Caption D Text Alignment BorderStyle Caption Text D 3 A GotFocus B LostFocus C SetFocus D Click GotFocus LostFocus Click SetFocus C 4 Visual Basic A Image C Frame B TextBox D CheckBox Frame TextBox Image CheckBox TextBox Image CheckBox C 42

55 2 Visual Basic 5 Text A Text1.Alignment=1 B Text1.Alignment=2 Text1.BorderStyle=0 Text1.BorderStyle=1 C Text1.Alignment=1 D Text1.Alignment=2 Text1.BorderStyle=1 Text1.BorderStyle=0 Alignment BorderStyle 0 1 A 6 ComboBox A List B ListIndex C AddItem D Move ComboBox List ListIndex AddItem ComboBox ComboBox Move C 7 A Activate B Deactivate C LostFocus D Initialize Activate Deactivate LostFocus Initialize Form MDIForm User Property Page Webclass DHIML PageDesigner C 8Name Form1 Name Text1 Text2 Name Command1, m = Text1.Text + Text2.Text Print m Private Sub Form_Load() 43

56 Visual Basic Text1.Text = "" Text2.Text = "" Text1 Text A 579 B C D Form_Load Command1_Click Text Text1.Text+Text2.Text C 9 True A Value B Enabled C Cancel D Default Value Variant / Enabled Cancel Default B 10 Label1 A Label1.BackStyle=0 B Label1.BackStyle=1 Label1.BorderStyle=0 Label1.BorderStyle=1 C Label1.BackStyle=True D Label1.BackStyle=False Label1.BorderStyle=True Label1,BorderkStyle=False BackStyle 0 1 BorderStyle 0 1 True False A 11 Combo1 Command1 Combo1 44

57 2 Visual Basic m = InputBox(" 0 2 ") a = Combo1.List(m) Print a Private Sub Form_Load() Combo1.AddItem "12" Combo1.AddItem "34" Combo1.AddItem "56" 2 A 12 B 34 C 56 D 0 Combo1 Command1 Command1_Click Form_Load Combo1 AddItem Combo1.AddItem [ ] 0 Form_Load Combo1 AddItem Command1_Click InputBox 2 a=combo1.list(m) a Print a 56 C 12 False A Enabled B Timer C Visible D Interval TimerEnable True Interval Interval 45

58 Visual Basic Timer Timer Visible A 13 picturefile.jpg Picture1 LoadPicture LoadPicture Picture1 Picture Picture1. Picture = LoadPrcture("picturefile.jpg") A ScrollBars B BorderStyle C MaxLength D MultiLine 2 A Click B GotFocus C Change D LostFocus 3 A ScrollBars B SelText C PasswordChar D Text 4 A BackStyle B FillStyle C BorderStyle D Shape 5 A Shape B ScrollBars C BorderStyle D BackStyle 6 Esc A Enable B Visible C Cancel D Style 7 A Click B KeyUp 46

59 2 Visual Basic C DbClick D GotFocus 8 Picture DownPicture DisablePicture A B C D 9 A Click B DropDown C DbClick D Change 10 A B C D 11 A Scroll B MouseMove C Change D DragOver 12 A B C D 13 A B C D 14 A F4 B F3 C Tab D Alt+Tab 15 A SetFocus B Visible C Refresh D GetFocus 16 Command1 Label1 Command1 Click Dim a(3) As Single Dim p As String For n = 0 To 3 a(n) = Val(InputBox(" " & (n + 1) & " ")) Next p = a(0) & ";" & a(1) & ";" & a(2) & ";" & a(3) Label1.Caption = p 47

60 Visual Basic InputBox A B 1234 C D 1;2;3;4 17 Name Text1 Tex12 Name Command1 x = 0 Do While x < 10 x = (x + 2) * (x + 3) n = n + 1 Loop Text1.Text = Str(n) Text2.Text = Str(x) A 1 0 B 2 72 C 3 50 D Visual Basic A Show B Hide C Load D UnLoad 19 OptionButton Index 1 2 CommonDialog Private Sub Form_Load() Static FlagFormPainted As Integer If FlagFormPainted <> True Then Option1(1).Caption = "Color" Option1(2).Caption = "Font" Command1.Caption = "Show Dialog" FlagFormPainted = True End If If Option1(1).Value Then 48

61 2 Visual Basic CommonDialog1.ShowColor ElseIf Option1(2).Value Then CommonDialog1.Flags = cdlcfboth CommonDialog1.ShowFont End If A Color Font B Color Font C Color Font D Color 256 Font 20 Private Sub Form_Load() List1.AddItem "357" List1.AddItem "246" List1.AddItem "123" List1.AddItem "456" Text1.Text = "" Private Sub List1_DblClick() a = List1.Text Print a + Text1.Text A 456 B C D Name Combo1 Private Sub Form_Load() Combo1.Text = "1" For I = 1 To 10 Sum = Sum + I 49

62 Visual Basic Next I Combo1.Text = Sum A B Combo1 55 C Combo1 1 D Combo1 1 1 Visual Basic Visual Basic 3 Visual Basic Value Visual Basic 5 Timer1 Timer Timer1.lnterval= Name Command1 Command2 Command1 Command2 Command2 Command1 Private Sub Command2_Click() 1 Private Sub Form_Load() 2 7 Command1 ListBox 50 Dim n As Long

63 2 Visual Basic Dim L1 As Boolean, L2 As Boolean, L3 As Boolean List1.Clear For n = 1 To 100 L1 = n = n ^ 2 Mod 10 L2 = n = n ^ 2 Mod 100 L3 = n = n ^ 2 Mod 1000 If L1 Or L2 Or L3 Then List1.AddItem n End If Next ListBox Visual Basic 2 1. Visual Basic 6 Visual Basic Ctrl+E 51

64 Visual Basic & Alt+ Visual Basic Caption Name ID 0-None 1-Left 2-Middle 52

65 2 Visual Basic 3-Right

66 Visual Basic Enabled = True.Enabled = False 2 MS-Word \ MS-Word.Checked = True 54

67 2 Visual Basic.Checked = False 3 Visual Basic Alt+ & Copy o C&opy 3. MS-Word 4. Windows Visual Basic.PopupMenu [ Flags X Y BoldCommand] PopupMenu X Y Flags X Y 55

68 Visual Basic Flags=0 X Y Flags=4 X Y Flags=8 X Y BoldCommand Flags vbpopupmenuleftalign 0 X Y vbpopupmenucenteralign 4 X Y vbpopupmenurightalign 8 X Y Flags vbpopupmenuleftbutton 0 vbpopupmenurightbutton 8 Flags Or MouseDown If Button=2 Then PopupMenu A Ctrl+E B C D Shift+Alt+M 3 Shift+Alt+M D 2 A % B * C & D # & & Alt Alt+S &S S & & && & 56

69 2 Visual Basic C 3 MenuItem A MenuItem. Enabled=False B MenuItem. Enabled=True C MenuItem. Visible=True D MenuItem. Visible=False Enabled True Visible True A 4 Visual Basic 1 Caption 2 Name Visual Basic Caption Name Visual Basic Visual Basic Menu1 A Menu1.Enabled =True B Menu1.Enabled = False C Menu1.Visible = True D Menu1.Visible = False 2 Menu1 A Menu1.Enabled =True B Menu1.Enabled = False C Menu1.Visible = True D Menu1.Visible = False 3 A Click B LostFocus C Change D GetFocus 4 A MouseDown B DragDrop C KeyDown D KeyPress 57

70 Visual Basic 5 Visual Basic A 4 B 6 C 8 D 10 6 A B C D 7 Menu1 A Menu1.Enabled =True B Menu1.Enabled = False C Menu1.Checked = True D Menu1. Checked = False 8 A B C D 9 A Enabled B Checked C PopupMenu D Menu Visual Basic Visual Basic 5 Visual Basic 6 Visual Basic 7 Visual Basic 58

71 2 Visual Basic 2.4 Visual Basic 1 Visual Basic Visual Basic 2 3 Visual Basic 3 Visual Basic Name Caption BorderStyle Enabled Visible AutoRedraw BackColor ForeColor Click DbClick Load UnLoad Activate Deactivate 4 Visual Basic 3 ActiveX ActiveX SetFocusGetFocus LostFocus 10 Tab Tab Tab 11 Visual Basic Visual Basic BorderStyle 59

72 Visual Basic A 0-None B 1-Fixed Single C 2-Sizeable D 3-Fixed Dialog 2 Visual Basic A B Shift C Ctrl D Alt 3 Visual Basic A Click Show B Show C LostFocus D GotFocus 4 Visual Basic A Load B Unload C Show D Hide 5 A B C ActiveX D OLE 6 Visual Basic A KeyDown B KeyUp C KeyPress D Click 7 A SetFocus B LostFocus C GotFocus D Click 8 Text A Text1.Alignment=1 B Text1.Alignment=2 Text1.BorderStyle=0 Text1.BorderStyle=1 C Text1.Alignment=1 D Text1.Alignment=2 Text1.BorderStyle=1 Text1.BorderStyle=0 9 A Move B Change C Scroll D Getfocus 10 Label1 A Label1.BackStyle=0 B Label1.BackStyle=1 Label1.BorderStyle=0 Label1.BorderStyle=1 C Label1.BackStyle=0 D Label1.BackStyle=1 Label1.BorderStyle=1 Label1,BorderkStyle=0 11 Combo1 Command1 60

73 2 Visual Basic a = Combo1.List(1) Print a Private Sub Form_Load() Combo1.AddItem "12" Combo1.AddItem "34" Combo1.AddItem "56" A 12 B 34 C 56 D 0 12 A LostFocus B OutFocus C Lost D Fause 13 ListBox1 Dim a, i, msg msg = "Choose OK to add 100 items to your listbox." MsgBox msg For i = 1 To 100 a = "a: " & i List1.AddItem a Next i A AddItem 100 B AddItem 100 1~100 C AddItem 1~100 D AddItem Label1 A Label1.Enabled = False B Label1.Enabled = True C Label1.Visible = True D Label1.Visible = False 15 Visual Basic ( ) A Shift+Ctrl B Shift+ C Ctrl+ D Ctrl+ 61

74 Visual Basic 16 Txt1 A Txt1.MultiLine=True B Txt1.MultiLine=True Txt1.ScrollBars=0 Txt1.ScrollBars=3 C Txt1.MultiLine=False D Txt1.MultiLine=False Txt1.ScrollBars=0 Txt1.ScrollBars=3 17 Value A Move B Change C Scroll D GotFocus 18 Form1 A Load Form1 B Form1.Show C Form1.Hide D Unload Form Command1 Command2 Command3 Command2.Enabled = False Command3.Visible = False A Command1 Command2 Command3 B Command1 Command2 Command3 C Command1 Command2 Command3 D Command1 Command2 Command3 20 Combo1 Chardonnay Fun_ Blanc Gewrztraminer Zinfandel Combo1 Private Sub Form_Load() Combo1.AddItem "Chardonnay" Combo1.AddItem "Fun_ Blanc" Combo1.AddItem "Gewrztraminer" Combo1.AddItem "Zinfandel" text1 A Text1.Text = Combo1.List(0) B Text1.Text = Combo1.List(1) C Text1.Text = Combo1.List(2) D Text1.Text = Combo1.List(3) 62

75 2 Visual Basic 21 PictureBox A Set Picture1.Picture = LoadPicture("c:\Win1.bmp",vbLPLarge, vblpcolor) B Picture1.Picture = LoadPicture("c:\Win1.bmp",vbLPLarge, vblpcolor) C Set Picture1.Pricture = LoadPicture D Priture1.Picture = LoadPicture 22 Visual Basic A & B * C $ 23 Visual Basic A B C D 1 Visual Basic ActiveX 3 1 ActiveX Name 3 Visual Basic 4 Visual Basic Visual Basic Text 6 Save v 63

76 3 Visual Basic 1 Visual Basic Visual Basic Visual Basic Visual Basic Visual Basic 4 Visual Basic 4.frm.bas.cls

77 3 Visual Basic.vbp 5 Visual Basic.exe 2. Visual Basic F

78 Visual Basic 3. Visual Basic Visual Basic 3 4. Visual Basic Visual Basic Visual Basic Visual Basic Visual Basic Windows Visual Basic.exe.EXE Visual Basic 3 Debug.Print Visual Basic Visual Basic 4.frm 66

79 3 Visual Basic.bas.cls.vbp 1.frm 2.bas 3.cls 4.vbp 2 Visual Basic Visual Basic Visual Basic A B C Stop D Visual Basic 4 Stop B B 5 a = 10: b = 50 Rem Print a;b 67

80 Visual Basic ' Print b;a Print a; b A B C D REM [ ] ' [ ] Visual Basic REM ' B 6 A B F7 C D 4 F7 A A 7 a = 1: b = 2: c = 3 a = b: b = c: c = a Print c A 0 C 2 B 1 D 3 a = 1 b = 2 c = 3 a = b a = 2 b = 2 c = 3 b = c a = 1 b = 3 c = 3 c = a a = 2 b = 3 c = 2 c 68

81 3 Visual Basic 2 C Visual Basic A.doc.txt B.com.exe C.vbp.frm D.bat.sys 2 x = "X" y = "Y" z = "Z" x = y: y = z: z = x Print x; y; z A YZY B Y Z Y C YZX D Y Z X 3 A My Documents B VB98 C \ D Windows 4 Visual Basic A.vbp B.bas C.frm D.cls 5.exe.exe A.frm B Visual Basic C D 6 69

82 Visual Basic a = 1 b = 2 a = b + a b = a b a = (a + b) / 2 b = a b Print "a=";a;";b=";b A a=1;b=2 C a=3;b=1 B a=2;b=1 D a=3;b= Visual Basic REM 3 Visual Basic Visual Basic 1 2 Visual Basic Visual Basic Integer Long

83 3 Visual Basic Float E e e e e 45 Double d e d d d d String ASCII Visual Basic ASCII 0 Visual Basic Currency Variant Visual Basic 5Byte 8 0~255 6Boolean 7Date :00:00 23:59:59 mm/dd/yy hh:mm:ss # 8Object 4 71

84 Visual Basic 9 Decimal Decimal Decimal 0 +/ / Visual Basic Decimal Decimal 2. Visual Basic Type Type As As End Type Type GuestInfo FirstName As String*10 LastName As String*10 Age As Integer End Type GuestInfo FirstName LastName Age FirstName LastName Age * FirstName As String*10 72

85 3 Visual Basic Type Public Private Type Private 3. 1~12 ~ [Public Private] Enum [=] [=] End Enum Public Enum Days Sunday = 0 Monday = 1 Tueday = 2 Wednesday = 3 Thursday = 4 Friday = 5 Saturday = 6 End Enum Long Visual Basic workday = Days.Saturday 1 Enum Public Private Visual Basic ASCII 73

86 Visual Basic ASCII Visual Basic ASCII 0 Visual Basic Visual Basic A Double B Boolean C Integer D Variant Integer 16 Double 64 Boolean Variant Visual Basic D 3 Double A 2 C 8 B 4 D 16 Double 64 8 C 4 DateTime Date A DateTime="5/12/03" B DateTime=September 1, 2003 C DateTime=#12:15:30 AM# D DateTime=("8/8/99") Visual Basic # B C 5 A B Type Public C Type Public Private D 74

87 3 Visual Basic Type Public Private Type Private * C 6 Public Enum WeekDays Sunday = 0 Monday Tuesday Wednesday Thursday Friday Saturday Invalid = -1 End Enum Dim myday As WeekDays myday = Saturday Print Val(myday) A Saturday B 6 C false D 1 Monday Saturday WeekDays =[] Sunday 0 1 Saturday 6 B

88 Visual Basic Dim b As Single b = 2# / 3 Print b A B 1 C 0 D Dim x As Single x = Print x A 5.5E 7 B 5.5E 07 C D Public Enum Number One Two Three Four = 4 Five Six Seven End Enum Dim num1 As Number Dim num2 As Number num1 = Two num2 = Six Print Val(num1),Val(num2) A 1 6 B 2 6 C 1 5 D

89 3 Visual Basic Dim MyString As String Dim MyLen As Integer MyString = "Visual Basic 6.0" MyLen = Len(MyString) MsgBox MyLen A Visual Basic 6.0 B 14 C 16 D 18 5 a$ = "This is a book." b$ = "That is an apple." c$ = Left$(a$, 8) + Right$(b$, 9) Print c$ A This is a book. B This is an apple. C That is an apple. D That is a book. 6 a$ = "AAAAAA" a$ = Mid$(a$, 2, 4) Print a$ Mid$(a$, 2, 2) = "aa" Print a$ A AaaA B AAAA C aaaa D aaaa AAAA AaaA aaaa AAAA 7 A Type B Enum C Public D Dim 8 77

90 Visual Basic Dim c As Long c = 1111 c& = 6666 Print c; c& A B C D Dim Index% A Dim Index As Long B Dim Index As Integer C Dim Index As Single D Dim Index As Double 10 Type Address Street As String * 20 ZipCode As String * 6 Phone As String * 8 End Type Dim MyHome As Address With MyHome Street = " " ZipCode = "100081" Phone = " " End With Print MyHome.Phone A B C D Type Person no As Integer name As String * 13 brith As Date salary As Single End Type Dim zhao As Person 78

91 3 Visual Basic A B C D 12 Public Enum StudentNames zhao qian= -1 sun li zhou wu = 10 zheng wang End Enum Dim name1 As StudentNames,name2 As StudentNames name1 = sun name2 = wang Print Val(name1), Val(name2) A 2 8 B 2 7 C 0 12 D Visual Basic A Double B Variant C Integer D Default 1 Integer 2 Long 3 Visual Basic 89% Enum Test num = 0 ab = 5 79

92 Visual Basic cd End Enum Test. cd 6 books no 40 name 20 score 10 brithdate Type books no As String*40 name As String*20 score1 1 brithdate 2 End Type 7 a = 12: b = 34.5: c$ = "a-b" s$ = c$ + "=" + Str$(a - b) Print s$ 8 name age wage Type student nam As String*12 age As Integer wage As Integer 80

93 3 Visual Basic ASCII &H &H1a &H0 &HFFFF &O &O37 &O0 &O &H & &H1a2b& &H0& &HFFFFFFFF& &O & &O3745& &O0& &O & E =1230 E E D % &! # 81

94 Visual $ Const = Const Visual Basic 2. Visual Basic 255 Visual Basic Visual Basic UserName 1 % 82

95 3 Visual Basic &! $ 2 Declare As As Declare Dim Static Redim Public Private 1 Dim Dim Declare Dim Var1 As Integer String String * Dim Str1 As String Str1 Dim Str2 As String *10 Str2 10 Visual Basic Dim Var1 Dim Var1$ Dim Var1 As String Dim Dim Var1 As String Var2 As Integer Dim Var1 Var As String Var1 Var2 Static Redim Public Private 2 Static Dim Static Dim Static 3 Public 4 Redim 3 DefType DefType DefType Def Type Def 83

96 Visual Basic - DefInt A-C A B C Type Type Type Int Lng Sng Dbl Cur Str Byte Bool Date Obj Var As DefType DefInt A Dim AdminName$ AdminName. MyData Type MyData DataID As Integer DataName As String *10 84

97 3 Visual Basic DataTime As Date End Type LastData MyData Static LastData As MyData LastData.DataID LastData.DataName LastData.DataTime 3. Visual Basic 3. Dim Private Private Public Public Global Dim Private Dim Static Dim Private Public Global Visual Basic 85

98 Visual Basic IDE Option Explicit Dim sum As Integer sum% = 10 sum = 3.2 Print sum%; sum A B C D 3 3 Dim sum sum % sum sum% sum sum 10 sum 3.2 VB 3 Print sum D 2 Dim Index# A Dim Index As Long B Dim Index As Integer C Dim Index As Single D Dim Index As Double As % &! $ D 3 A Dim B Public 86

99 3 Visual Basic C Static D Const Visual Basic Const Dim Static Public D 4 Dim Str1,Str2 As String *10 Str1 1 Str2 2 Str1 Str2 Str2 10 Str1 Visual Basic Dim Str1 Str Visual Basic a% = 2/3 b% = 32/9 Print a%; b% A 1 4 B

100 Visual Basic C 1 3 D A B C D Const 3 Visual Basic A 127 B 255 C 511 D Visual Basic A B C D 5 A Dim B Public C Static D Const 6 Visual Basic A B C D 7 A Dim B Public C Static D Private 8 A dim B zh_1 C a.b D 12b 9 Dim MyVar MyVar="Hello World!" Debug. Print MyVar A True B False C Hello World! D " Hello World!" 88

101 3 Visual Basic 10 Visual Basic A Add B AddItem C AddString D AddObject Const Const Visual Basic Int(x) Fix(x) Hex$(x) Oct$(x) Asc(x$) x x$ ASCII 89

102 Visual Basic Chr$(x) x ASCII Val(x$) x Str$(x) x Cint(x) x Ccur(x) x 4 Cdbl(x) x Clng(x) x Csng(x) x Cvar(x) x Sin(x) x x Cos(x) x x Tan(x) x x Atn(x) x Abs(x) x Sgn(x) x x Sqr(x) x Exp(x) e x Day(Now) WeekDay(Now) Month(Now) Year(Now) Hour(Now) 0~23 Minute(Now) Second(Now) 90

103 3 Visual Basic Now Rnd(x) 0 1 Randomize(x) Ltrim$( ) Rtrim$( ) Trim$( ) Left$(,n) Right$(,n) Mid$(,p,n) Len( ) Sting$(n,ASCII ) Space$(n) Ucase$( ) Lcase$( ) InStr([,] 1 2[,n]) Mid$( [ L])= Tab n n p n n p n ASCII ASCII n n n=0 n=1 n= Null Null L L $ ANSI B StrConv ANSI Unicode = StrConv 91

104 Visual Basic 64 ANSI Unicode 128 Unicode ANSI 2. Visual Basic 1 ^ x^y + x+y x y * x*y / x/y \ x\y x Mod x Mod y 2 Visual Basic + & A$+B$ A$&B$ B$ A$ 3 = <> >< < 92

105 3 Visual Basic > <= >= Like Is a<x<b ASCII ASCII Like Is Like SQL Is 4 Not And Or Xor Eqv Imp X Y Not X X And Y X Or Y X Xor Y X Eqv Y X Imp Y Not And Or Xor Eqv Imp

106 Visual Basic ~ * [ ]{ } Visual Basic Visual Basic 1 2 ASCII 3 1 Str$(x) 2 Val(x$) 3 Asc(x$) 3 a1 = "123" a2 = "123a" a3 = "12a3" a4 = "a123" Print Val(a1); Val(a2); Val(a3); Val(a4) 1 Visual Basic Val C ASCII 67 94

107 3 Visual Basic ascii = 67: c = "C" Print Tab(10); c For i = 1 To 2 c = Chr(ascii - i) + c + Chr(ascii + i) Print Tab(10 - i); c Next i A C B A BCB BAB ABCBA CBABC C C D C BCD DCB ABCDE EDCBA Chr() Tab() Chr() ASCII Tab() C ASCII 67 C ASCII c ASCII ASCII (ascii i) (ascii+i) c c Tab(10 i) c C 5 x = Sqr(2) + Sgn(2)+ Rnd(2) *10 y = Sqr(3) + Sgn(3) + Rnd(3) *10 If x > y Then Print "x>y" ElseIf x = y Then Print "x=y" Else Print "x<y" End If 95

108 Visual Basic A x>y C x<y B x=y D If Then Else end If x Sqr() Sgn() Rnd(3) Sqr() x Sgn(x) x Rnd(x) 0 1 y x y If Then Else end If x>y x>y x=y x=y x<y x y x y D 6 x = "12.34": y = "56.78" z = x + y p = Val(z) Print p A B C D x y z=x+y z Val() z pval() 2 D 7 Dim a As Single a = b = Int(a) c = Sgn(a) d = Abs(a) e = Fix(a) If a < b Then Print b; If a < c Then Print c; 96

109 3 Visual Basic If a < d Then Print d; If a < e Then Print e; Print A B C D Int(x) Sgn(x) Abs(x) Fix (x) Int(x) x Fix(x) x Int(x) Fix(x) x Int(x) Fix(x) 1 Abs(x) Sgn(x) a Int(a) Sgn(a) Abs(a) Fix (a) b c d e IF THEN a b a c a d a e b c d C 8 Visual Basic x=8 A B C D Visual Basic = x=8 = x=8 x=8 = x=8 B 9 Visual Basic A x=x+y B x+y>z C x=(x=y) D D 10 Sin30 Visual Basic A Sin30 B Sin(30) C SIN(30 ) D Sin(30*3.14/180) Sin() D 11 S 4 97

110 Visual Basic A Right(S,4) C RightStr(S) B Left(S,4) D RightStr() Right Rigth(, n) n Left Left(, n) n S 4 Right(S,4) A 12 S 6 4 A Mid(S, 6, 4) B Mid (S, 4, 6) C MidStr(S, 6, 4) D MidStr(S, 4, 6) Mid() Mid(,p,n) p n n p Visual Basic MidStr() S 6 4 Mid(S,6,4) A 13 A Len() B Length() C StrLen() D StrLength() Len()Len( ) Visual Basic B C D A 14 S 4 A Left (S,4) B Left(1,4) C LeftStr (S) D LeftStr (S,4) Left() Left(, n) n Visual Basic LeftStr() A \ 6 * 7 Mod 8 / 9 A 4 B 5 C 6 D 7 98

111 3 Visual Basic ^ * / \ Mod +& A For i = 1 To 4 x = 1 For j = 1 To 3 x = 2 For k = 1 To 2 x = x + 6 Next k Next j Next i Print x A 2 B 7 C 14 D 37 2 x = 0 Do Until x = -1 a = InputBox(" A ") a = Val(a) x = InputBox(" X ") x = Val(x) a = a * x Loop Print a 99

112 Visual Basic A 120 C 15 3 x x + B 15 D 120 y + sin 2x Visual Basic y A SQR(x+y)/(x y)+sin(x*2) B SQR(x+y)/(x y)+sin(2x) C SQR((x+y)/(x y))+sin(x*2) D SQR((x+y)/(x y))+sin(2x) 4 a = 1234 b$ = Str(a) c = Len(b$) Print c A 4 B 5 C 6 D 7 5 a = 1.2 b = 345 c = Len(Str$(a) + Str$(b)) Text1.Text = c A 3 B 4 C 6 D 8 6 a = Text1.Text b = Text2.Text c = LCase(a) d = UCase(b) 100

113 3 Visual Basic Print c; d ABCD efgh A abcdefgh B abcddfgh C ABCDefgh D ABCDEFGH 7 a$ = "123" b$ = "456" c = Val(a) + Val(b) Print c A 123 B 456 C D A Int(5.4) + Int( 5.8) B CInt(5.4) + CInt( 5.8) C Fix(5.4) + Fix( 5.8) D Exp(5.4) + Exp( 5.8) 9 a$ = Text1.Text s$ = "" For k = 1 To Len(a$) s$ = UCase$(Mid$(a$, k, 1)) + s$ Next k fns$ = s$ Text1.Text = s$ A B C D 10 Fix(12) + Fix( 12.8) A 0 B 1 C 1 D True 101

114 Visual Basic 11 Fix( 45.6) + Int(12.3) A 33 B 33 C 34 D a = "aaaaaa" b = Mid(a, 2, 4) Mid(a, 2, 4) = "AAA" Print a, b A aaaa aaaaaa B aaaaa aaaa C aaaaaa aaaa D aaaa aaaa 13 ^ / Mod * A ^ B / C Mod D * 14 Not Xor Or And A Not B Xor C Or D And 15 A B C D 16 Visual Basic A x=sgn(0) B x=sqr(0) C x=log(0) D x=sin(0) 17 a=8 <CR> b=9 <CR print a<b <CR> A 1 C False 18 Int(Rnd(0)*10) A 0,10 B 0 D True B 0,1 102

115 3 Visual Basic C 1,10 D 1,2 19 x 200 A x < 200 B x < 0 AND x > = 200 C x < 200 AND x > = 0 D 200 > x > = <> 4 Or Not 2 * 5 A 0 B 1 C true D false 1 a$ = " " d$ = Left$(a$, 1) For I = 2 To Len(a$) z$ = Mid$(a$, I, 1) If z$ > d$ Then d$ = z$ Next I Print d$ 2 Int( Sqr(6.4)) 3 7 ^ 2 Mod 5 ^ 2 / 3 4 1/2 2x 3 +ln x 1 Visual Basic 5 (30 Mod 5 * 7 + 8) \ 12 + ll * (5 * 5 \ 12 / 2 ^ 2 + 3) 6 (Fix(32.4) + Int( 32.4) + Sgn(32.4)) 7 a$ = "Good morning!" b$ = "Even" c$ = Left$(a$, 5) + LCase$(b$) + Right$(a$, 4) Print c$ 103

116 Visual Basic 8 x Visual Basic 9 a B X 7 ASCII 10 2(1+ln3x) Visual Basic 11xyz Abc > (12 3) / 3 Or Not 6 <> 5 3 * 7 13 a$ = "12.3" b = "45.6" c = Val(a$) + Val(b) Print c 14 (a b)/(1+x*x Exp(x)) 15 a = 1.23 b$ = "1.23" c = Len(Str$(a) + b) Text1.Text = c Visual Basic 1023 _ 104

117 3 Visual Basic Visual Basic 2 < > [ ] { }, 3 Visual Basic 3 1 [Let] = Let = 2 105

118 Visual Basic Rem ' _ 3 Stop Stop 4 End End End End End End Function End If If End Type End Select 4 If If Then 1 [Else 2] Visual Basic 1 2 If If Then Else If Then Else Else If Then 106

119 3 Visual Basic If 1 Then 1 [ElseIf 2 Then 2] [ElseIf 3 Then 3] [Else n] End If ElseIf n 0 0 Then Visual Basic Then EndIf ElseIf ElseIf Visual Basic IIf IIf IIf(< > < 1> < 2>) IIf 1 IIf 2 IIf 107

120 Visual Basic Visual Basic Select Case Select Case Case Select Case Case 1 1 [Case 2 [ 2]] [Case Else [ n]] End Select Select Case Else Select Case [ ] Case To Case 1 To 5 Is Case Is=5 Case Is>10 And Is<20 Select Case Case Case Else Case Case Case 6 For Visual Basic 3 For Do 108

121 3 Visual Basic For For = To [Step ] [ ] [If Then Exit For] Next [ ][] Visual Basic Exit For Next For For Int / +1 For For For i = 1 To 5 For j = 1 To 10 Print i Next i Print j Next j For Next Next For Next Next 109

122 Visual Basic Exit For Exit For 7 While [ ] Wend While Wend Wend While 8 Do Do 1 Do [ ] [If Then Exit Do] Loop [While Until ] 2 Do [While Until ] [ ] [If Then Exit Do] Loop 110

123 3 Visual Basic Do Loop While Until Exit Do For Exit For While Until Do 1 Do While Until Do 2 While Until Do For 9 For i = 1 to 10 step 2 Text2.Text = i Next Do Counter = Counter +1 For i = 1 to Counter step 2 Text2.Text = i Next Loop Until Counter>

124 Visual Basic Do Counter = Counter +1 For i = 1 to Counter step 2 Text2.Text = i While i<10 Print Counter Wend Next Loop Until Counter>100 Visual Basic Exit Exit For Exit Do 10 GoTo GoTo GoTo On-GoTo GoTo GoTo GoTo { } GoTo GoTo On-GoTo On GoTo On Counter+Number GoTo Counter+Number On-GoTo 112

125 3 Visual Basic GoTo Visual Basic GoTo GoTo On-GoTo Visual Basic A B C D_ Visual Basic 1023 _ C 3 Visual Basic A For B Select Case C While D Do Visual Basic 3 For While Do For While Do Visual Basic Select Case B 4 Name Text1 Tex12 Name Command1 x = 1:n=0 Do While x < 100 x = x * 10 n = n + 1 Loop 113

126 Visual Basic Text1.Text = Str(n) Text2.Text = Str(x) A 10 0 B C 3 50 D Do While Loop While x < 100 x < 100 Do While x=10 n=1 Do While x=100 n=2 Str Text1.Text = Str(n) n Text1 B 5 x = 0 Do Until c = -1 a = InputBox(" A ") a = Val(a) b = InputBox(" B ") b = Val(b) c = InputBox(" C ") c = Val(c) a = a + b + c Loop Print a A 2 B 3 C 14 D 15 Do Until Loop Until c = 1 c = 1 Do Until InputBox 114

127 3 Visual Basic Val 3 12 a c = a 2c = 1 A 6 For i = 1 To 2 For j = 1 To i For k = j To 6 a = a + 1 Next k Next j Next i Print a a A 6 C 17 B 14 D 32 For i = 1 To 2 j = 1 To ii = 1 i = 2 k = j To 6 j = 1 j = 2 1 i=1,j=1 k 6 a 6 2 i=2,j=1 k 6 a 12 3 i=2,j=2 k 5 a 17 C 7 Dim i For i = 1 To 10 Step 2 i = i + 1 Print i; Next i 115

128 Visual Basic A B C D For i Step 2 2 Print Print D 8 For Next A Exit B Exit For C Continue D Stop Loop For Next Exit For B A Do While (condition) B Do Statements Statements Loop Loop While(condition) C Do Until(condition) D Do Until(condition) Statements Statements Loop End Do 2 Visual Basic A For Next B For Each Next C With End With D Do Loop 3 Click Cls Print For n = 1 To 6 Print Spc(1); "*"; Next n 116

129 3 Visual Basic Print A ****** B * * * * * * C * ** ** * D ** ** ** 4 WHILE A B C D 5 Do Until Loop A B C D 6 Private Sub form_click() Static sum As Integer i = 1 While i <= 10 sum = sum + i i = i + 1 Wend Print sum A B C D a = 0 For m = 1 To 10 a = a + 1 b = 0 For j = 1 To

130 Visual Basic a = a + 1 b = b + 2 Next j Next m Print a; b A B C D Visual Basic A GoTo B While Wend C For Next D On GoTo 9 a = 1 b = 1 For i = 1 To 3 a = a + b b = b + a Next i Print a; b A 2 3 B 5 8 C D A If a=3 And b=2 Then B If a=3 Then c=3 c=3 Else if a=2 Then c=2 End If C If a=3 Then D If a=3 Then c=3 c=2 ElseIf a=2 Then c=3 End If

131 3 Visual Basic a = 0 For i = 1 To 6 b = 0 For j = 1 To i a = a + 1 b = b + 2 Next j Next i Print a; b A B C D Dim a(3, 4) Static n As Integer For i = 1 To 3 For j = 1 To 4 n = n + 1 a(i, j) = n Next j Next i For i = 1 To 3 For j = 1 To 4 Print Tab(4 * j); a(i, j); Next j Print Next i A B C D

132 Visual Basic a = Text1.Text If a Mod 2 = 0 Then MsgBox " " Else MsgBox " " End If 23 A B C D 14 Function fact(n) s = 0 For k = 1 To n s = s + (k + 1) * k Next k fact = s End Function A N B N N C N 1 N D N 15 Dim i, MyNum Do For i = 1 To 1000 MyNum = Int(Rnd * 1000) 120

133 3 Visual Basic Select Case MyNum Case 7: Exit For Case 29: Exit Do Case 54: Exit Sub End Select Next i Loop A 7 B DO C D x = InputBox(x) If x Mod 3 = 0 Then y = x Mod 3 If x Mod 3 = 1 Then y = x Mod 3 If x Mod 3 = 2 Then y = x Mod 3 Print y 23 A 0 B 1 C 2 D 17 Sub ABC() Dim Number, MyString Number = InputBox(n) If Number = 1 Then GoTo L1 Else GoTo L2 L1: MyString = "Number = 1" Print MyString GoTo L3 L2: MyString = "Number < > 1" Print MyString L3: Print MyString 121

134 Visual Basic Call ABC InputBox 35 A Number 1 B Number <> 1 Number 1 Number <> 1 C Number 1 D Number <> 1 Number <> 1 Number 1 18 For j = 8 To 35 Step 3 Print j; Next j A 10 B 9 C 27 D For i = 1 To 6 a = a + i Next i Print a A 10 C B 15 D 28 s = 0 i = 1 While i <= 100 s = s

135 3 Visual Basic Wend Print s A 125 C 21 B 512 D 100 a = 100 Do s = s + a a = a + 1 Loop While s < 120 Print a A 100 B 120 C 201 D Name Text1 Private Sub Form_Load() Text1.Text = "" For i = 1 To 100 Sum = Sum + i Next i Text1.Text = Sum A Text B Text1 0 C Text1 D 23 Name Text1 Tex12 Name Command1 x = 1 Do While x <

136 Visual Basic x = x * 5 n = n + 1 Loop Text1.Text = Str(n) Text2.Text = Str(x) A 1 5 B 2 25 C D X 5 ABCDEF SELECT CASE A Select Case X B Select Case X Case 10 To 1 Case Is >15,Is<5 Print "ABCDEF" Case "ABCDEF" End Select End Select C Select Case X D Select Case X Case Is > 5, 1,3 To 10 Case 1,3,Is>5 Print "ABCDEF" Print "ABCDEF" End Select End Select 25 a$ = "*": b$ = "$" + a$ For k = 1 To 3 x$ = String$(Len(a$) + k, b$) Next k Print b$; x$ A $*$$$$ C $*$*$* 26 3 B *$*$*$ D $$$$*$ If x=1 Then y=4 If x=2 Then y=5 If x=3 Then y=6 A If x=1 Then B If x=1 Then 124

137 3 Visual Basic y=4 y=4 ElseIf x =2 Then ElseIf x =2 Then y=5 y=5 Else: y =6 Else y=6 End If End If C If x=1 Then D If x=1 Then y=4 y=4 ElseIf x =2 Then =5 ElseIf x =2 Then End If y=6 End If 1 c = 1 Do Until c = 10 c = c - 1 Loop Print c 2 x = "A": y = "B": z = "C" For i = 1 To 2 x = y: y = z: z = x Next i Text1.Text = x + y + z 3 For i = 1 To 2 For j = 1 To i For k = j To 6 125

138 Visual Basic m = m + 1 Next k Next j Next i Print m 4 x = -1 While x < 5 x = x + 1: x = x * x Wend Print x 5 For a = 1 To 5 For b = 1 To 10 y = b For c = 1 To 6 x = x + 1 y = y + 1 Next c Next b Next a Text1.Text = y 6 x = 10: i = 1 z = Int(Rnd(Y) + 2) On z GoTo 10, 20, 30 i = i

139 3 Visual Basic 10: i = i : i = i : i = i + 30 Print i 7 Sum = 1 For x = 1 To 10 Step 0.4 Sum = Sum + 1 Next x Print Sum Sum / 3 * 5 Mod (2 / 3) 9 1~6 10 "This"+" is "+"a book." 11 Fix( ) + Int(98.765) Visual Basic S(n) S n S(1) S 1 m m S(n 1,n 2,,n m ) Visual Basic 127

140 Visual Basic 2 1 Visual Basic Dim ReDim Static Public 1 Dim As Dim 1 2 As Dim test(5) As Integer test 6 0~5 Variant 0 Visual Basic Option Base Option Base 1 1 Option Base 0 0 Option Base Option Base Dim [ To] [ [ To] ] Dim title( 5 To 3) title 5~

141 3 Visual Basic Option Base Lbound [ ] Rbound [ ] Dim Public ReDim Dim test() As Integer ' Dim size Sub Form_Click() Size=InputBox("Enter value:"," data","12") Redim test(size) ' ReDim ReDim [Preserve] As ReDim Preserve ReDim ReDim ReDim 8 ReDim 60 ReDim 2 Erase Erase Erase Erase 0 129

142 Visual Basic 0 Empty Nothing Erase Redim 3 x(1)=100 For Print Print x(1) 4 For Each Next For Each Next For Each In [Exit For] Next[ ] For Next 130

143 3 Visual Basic For Each Next For Each Next Exit For 5 Visual Basic Array Array Dim As Variant =Array( ) Array 0 Option Base Dim Days As Variant Days = Array( ) Days(0) Days(6) 1 7 Dim Days(6) As Integer Days(0) = 1 Days(1) = 2 Days(2) = 3 Days(3) = 4 Days(4) = 5 Days(5) = 6 Days(6) =

144 Visual Basic Option1(1) Option Index Index Visual Basic Dim 2 Public 3 ReDim 4 Static 2 132

145 3 Visual Basic Variant Visual Basic Visual Basic Option Base Option Base 1 1 Option Base Option Base 4 Visual Basic Erase 1 2 Visual Basic Erase Redim A32 768~ B C Option Base 0 D ~ Option Base D 133

146 Visual Basic 7 A For Each Next B For Next C While Wend D Do Loop For Each Next A 8 Dim A( 3 To 5) as Integer A 6 B 7 C 8 D 9 3~5 9 0 D 9 Dim score(1 To 15)As Double A 16 B 15 C 16 D 15 1~ D 10 Static Ar(9,9) As Integer A 9 B 18 C 81 D 100 Array(0, 0) Array(9, 9) 100 D 11 Option Base 1 Dim a a = Array(1, 2, 3, 4) j = 1 For i = 3 To 0 Step -1 s = s + a(i) * j j = j *

147 3 Visual Basic Next i Print s A 12 B 123 C 1234 D For 1 i = 3 To 0 a(i) a(3) a(2) a(1) a(0) Option Base 1 1 For a(i) D Dim a(10), b(10) For j = 0 To 10 a(j) = j + 5 b(j) = a(j)/4 Next j Text1.Text = b(j\2) A 2.5 B 5 C 4.5 D Option Base 1 Dim a1(10), a2(4) As Integer m = 0 For i = 1 To

148 Visual Basic a1(i) = i Next i For i = 1 To 4 a2(i) = a1(i * 2) Next i For i = 1 To 4 m = m + a2(i) Next i Print m A 16 B 20 C 25 D 30 3 A ReDim Preserve A(10,Ubound(A,2)+1) B ReDim Preserve A(Ubound(A,1)+1,10) C ReDim Preserve A(Ubound(A)+1) D ReDim A((UBound)(A)+1) 4 Dim a(10) For j = 0 To 10 a(j) = j 5 Next j Text1.Text = a(a(6)/a(10)) A 5 B 1.6 C 0 D 5 Dim a(50) For j = 0 To 10 j = j * j a(j) = j Next j Text1.Text = a(25) 136

149 3 Visual Basic A 5 B 25 C 45 D 55 6 Dim a(10) For i = 1 To 10 a(i) = i ^ 2 Next i Print a(i 2) A 64 B 81 C 99 D Dim a(4, 4), b(4, 4) For i = 1 To 4 For j = 1 To 4 a(i, j) = i + j b(i, j) = a(i, j) + i + j Next j Next i For i = 1 To 4 For j = 1 To 4 Print Tab(4 * j); a(i, j) + b(i, j); Next j Print Next i A B

150 Visual Basic C D Dim n, s n = 1 If n > 1 Then GoTo l1 Else GoTo l2 l1: s = "n 1" GoTo l3 l2: s = "n 1" l3: MsgBox s An 1 Bn 1 C 1 D 9 Dim n, a n = 66 If n < 10 Then a = 1 ElseIf n < 100 Then a = 2 Else a = 3 End If MsgBox a 138

151 3 Visual Basic A 1 B 2 C 3 D 0 10 Dim c, a(20) c = 0 While c < 20 c = c + 1 a(c) = c Wend MsgBox a(10) A 10 C B 11 D 9 Private Sub Form_KeyPress(KeyAscii As Integer) a = Array(25, 320, 125, 12, 215, 47) c = a(0) t = 1 If KeyAscii = 13 Then For i = 1 To 5 If a(i) > c Then c = a(i) t = i End If Next i End If Print c Print t A 12 B 320 C 25 D

152 Visual Basic AWeek = Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat") today = AWeek(2) today = AWeek(6) MsgBox today A Sun B Tue C Sat D Thu 13 A For Next B For Each Next C While Wend D Do Loop 14 Dim A( 1 To 10) as Integer A 9 B 10 C 11 D x = 10 Dim a(x) For m = 1 To 6 a(m) = m + 1 Next A a(m) B C m D 1 Dim A(11 to 30) 2 s = 1 For m = 1 To 3 140

153 3 Visual Basic If m <= 1 Then a = 1 ElseIf m <= 2 Then a = 2 ElseIf m <= 3 Then a = 3 Else a = 4 End If Print a Sum = Sum + a Next m Print Sum; 3 Score = Int(Rnd) + 5 Select Case Score Case 5 a$ = "Good" Case 4 a$ = "OK" Case 3 a$ = "Pass" Case Else a$ = "Bad" End Select MsgBox a$ 4 k = 0 Do While k < 10 k = k + 2 a = a + k * k /

154 Visual Basic Loop MsgBox a 5 x = 6 If x > 6 Then Print "x > 6" Else If x < 8 Then Print "x < 8" Else If x = 6 Then Print "x = 6" End If End If End If 3.7 Visual Basic Visual Basic Visual Basic 1 Visual Basic 2 Visual Basic 3 Visual Basic 3 4 Visual Basic Visual Basic Windows.EXE 5 Decimal 142

155 3 Visual Basic Decimal Decimal 6 ASCII Visual Basic DefType 8 Visual Basic 3 9 Visual Basic 10 Visual Basic 11 Visual Basic 1023 _ 12 3 If Select Case Visual Basic 3 For Do GoTo GoTo On-GoTo

156 Visual Basic Visual Basic 14 4 Dim ReDim Static Public 15Erase Erase For Each Next 18 Visual Basic Array Array 19 Index Dim Index& A Dim Index As Long B Dim Index As Integer C Dim Index As Single D Dim Index As Double 2 Type Student no As Integer name As String *

157 3 Visual Basic brith As Date score As Integer End Type Dim stu1 As Student A B C D 3 A Dim B Global C Static D Private 4 a=6 x=iif(a>5, 1,0) x A 5 B 6 C 0 D 1 5 x x = 0 For i = 1 To 20 Step 2 x = x + i \ 5 Next i Print x A 16 B 17 C 18 D 19 6 For i = 1 To 4 x = 4 For j = 1 To 3 x = 3 For k = 1 To 2 x = x + 6 Next k Next j Next i Print x 145

158 Visual Basic A 7 B 15 C 157 D A My Documents B Visual Basic98 C \ D Windows 8 S 2 3 A Mid(S, 3, 2) B Mid (S, 2, 3) C MidStr(S, 3, 2) D MidStr(S, 2, 3) 9 Visual Basic A B C D 10 Tan 30 Visual Basic A Tan30 B Tan (30) C Tan (30 ) D Tan (30*3.14/180) 11 For i = 1 To 4 Print Tab(2 * i); 11 * i Next i A 11 B C D a = 4 b = 3 Print b > a A 1 B 0 146

159 3 Visual Basic C True D False 13 Visual Basic A Abcd B m1234 C 5554tre D x_ y 14 S 6 A Right(S,6) B Left(S,6) C RightStr(S) D Left Str(S) 15 a = b$ = " " c$ = Str(a) b2 = Len(b$) c2 = Len(c$) Print b2, c2 A B C 9 10 D a = 123 b = 456 c = Str(a) + Str(b) Print c A 123 B C D x = 5 Do Until x = -1 a = InputBox(" A ") b = InputBox(" B ") 147

160 Visual Basic If a > b Then x = -1 Loop Print Val(a + b) A 5 B 60 C 32 D Dim a(5) For m = 1 To 6 a(m) = m + 1 Next A a(m) B C m D 19 Dim a(10), b(10) For j = 0 To 10 a(j) = 3 * j b(j) = a(j) * 3 Next j Text1.Text = b(j / 2-0.1) A 25 B 50 C 45 D Dim n, s

161 3 Visual Basic n = InputBox("Input n:") If n > 1 Then GoTo l1 Else GoTo l2 l1: s = "n 1" GoTo l3 l2: s = "n 1" l3: MsgBox s 12 A n 1 B n 1 C 12 D 21 Dim a! A Dim a As Single B Dim a As Double C Dim a As Long D Dim a As Integer 22 A B C Type Public Private D Type Public 1 Dim i As Integer, m As Integer For m = 11 To 19 Step 2 For i = 2 To Int(Sqr(m)) If (m Mod i) = 0 Then GoTo LP Next i Print m; LP: Next m

162 Visual Basic Dim i As Integer, m As Integer For m = 101 To 199 Step 2 For i = 2 To m - 1 If (m Mod i) = 0 Then 1 Next 2 Print m Lp: Next Visual Basic 1.Print 2 5 Visual Basic Visual Basic Stop End Visual Basic Visual Basic ASCII

163 Print Print Print Print BASIC Print [ < >. ] Print [ ][, ; ] Form Debug PictureBox Printer [, ; ] 14 Print Print Print Print

164 Visual Basic 2. Print Visual Basic Print 1 Tab Tab( n ) Tab n Tab n n n n 1 Tab 2 Spc Spc( n ) Spc n 0~ Spc 3 Space$ Space$( n ) Space$ n 3. (Format$) Format$ Format$ (, [ ] ) 1 ## 2 0 # % 6 $ 7 8 E E E 152

165 4 4. Visual Basic 1 FontName FontName [ = " " ] 2 FontSize FontSize [ = ] 3 FontBold FontBold [ = Boolean ] Boolean True False 4 FontItalic FontItalic [ = Boolean ] Boolean True False 5 FontUnderline FontUnderline [ = Boolean ] Boolean True False 6 FontStrikethru FontStrikethru [ = Boolean ] Boolean True False 5. Visual Basic Print Printer Printer.Print [ ] 6. PrintForm [.]PrintForm

166 Visual Basic Private Sub Form_Activate() Print "aa"; "bb", "cc", "dd"; "ee"; "ff" Print 12; 34; 56, 78, 90; -11; 22; -33 Print Print "xx" & "yy", 36 * 2; Print 7 ^ 2, Print "End" Print Print Private Sub Form_Activate() Print " " Print " "; Tab(10); " "; Tab(20); " "; Print Tab(30); " " Print "001"; Tab(10); " "; Tab(20); " "; Tab(30); 98 Print "012"; Tab(10); " "; Tab(20); " "; Tab(30); 87 Print Print " " Print " "; Spc(6); " "; Spc(6); " "; Spc(6); " " Print "021"; Spc(6); " "; Spc(6); " "; Spc(6);

167 4 Tab n Tab Spc Tab Spc Tab(n) n Spc (n) n Private Sub Form_Click() Print Format$(1234.5,"000,000.00") Print Format$(1234.5,"###,###.##") Print Format$(1234.5,"- ###,##0.00") Print Format$(1234.5,"$###,## #.##") Print Format$(0.1234,"0.00%") Print Format$(123456,"0.00E+00") Print Format$(123456,"0.00E-00") Print Format$( ,"0.00E-00") Format$ Format$ a = "ABCD" For m = 1 155

168 Visual Basic Print Tab(5 - m); Next m D CD BCD a D a 1 CD a 1 2 BCD a a Right Right Rightn n m 1~3 For m = 1 To 3 Right(a,m) Tab 5 m Right(a,m) Tab 1 1 To 3 2 Right(a,m) 5 156

169 4 Private Sub Form_Click() FontName=" " FontSize=24 FontItalic=True FontUnderline=True Print " " FontName=" " FontSize=20 FontItalic = False FontBold = True FontUnderline = False Print " " PrintForm Print PrintForm Private Sub Form_Click() Printer.FontName=" " Printer.FontSize=24 Printer.FontItalic=True Printer.FontUnderline=True Printer.FontBold=True Printer.Print " " Printer.EndDoc 157

170 Visual Basic Print Format$( ,"000,000,00") A C 32, B 023, D 32, a = "12345" For m = 3 To 4 Print Tab(6 - m); Right(a, m) Next m A B C D 3 For j = 1 To 10 If j Mod 3 <> 0 Then a = a + j \ 3 Next j 158

171 4 Print a A 9 C 6 4 B D 0 a=sqr(3) Print Format$(a,"000.00") A C 17.3E 01 5 B 1.73 D s% = Print s% A B C 3.14 D 3 6 Print "Visual";"C++","Visual";"Basic" A VisualC++VisualBasic B Visual C++Visual Basic C VisualC++ VisualBasic D Visual C++ Visual Basic 7 Print "Visual"; Print "Basic", Print "6.0" A VisualBasic6.0 B VisualBasic 6.0 C Visual Basic6.0 D Visual Basic Visual Basic 159

172 Visual Basic A FontName B FontSize C FontBold D FontItalic 9 Visual Basic A Form1.Show B Form1.Print C Form1.Println D Form1.PrintForm 10 Visual Basic A Print B Printer C Show D Display 11 Visual Basic A FontUnderline B FontStrikethru C FontBold D FontItalic 1 For j = 1 To 3 Print ; 11 * (2 * j - 1); Next j 2 160

173 4 For j = 1 To 10 If j Mod 3 <> 0 Then a = a + j / 3 Next j Print Format$(a, 1 ) Print Format$(a, 2 ) 3 a = 10 1 b = "abc" Print a 2 b Print a 3 b InputBox Visual Basic InputBox InputBox InputBox ( prompt [,title] [,default] [,xpos,ypos] [,helpfile,context] ) 1 prompt

174 Visual Basic 2 title 3 default 4 xpos,ypos x y x y 5 helpfile 6 context 2. MsgBox MsgBox MsgBox MsgBox(msg[,type][,title][,helpfile,context]) MsgBox MsgBox msg$[,type%][,title$][,helpfile,context]) MsgBox MsgBox MsgBox 1 msg Chr$(13)+Chr$(10) 2 type vbokonly 0 vbokcancel 1 vbabortretryignore 2 vbyesnocancel 3 vbyesno 4 vbretrycancel 5 vbcritical 16 Critical Message vbquestion 32 Warning Query vbexclamation 48 Warning Message vbinformation 64 Information Message vbdefaultbutton

175 4 vbdefaultbutton2 256 vbdefaultbutton3 512 vbdefaultbutton title 4 helpfile 5 context MsgBox MsgBox 1 vbok 2 vbcancel 3 vbabort 4 vbretry 5 vbignore 6 vbyes 7 vbno InputBox Private Sub Form_Click() msgtitle$=" " ch$=chr$(13)+chr$(10) msg0$="[ ] " msg1$=" "+ ch$+ msg0$ msg2$=" "+ ch$+ msg0$ msg3$=""+ ch$+ msg0$ studname$=inputbox(msg1$,msgtitle$) studsex$=inputbox(msg2$,msgtitle$," ") 163

176 Visual Basic studcard$=inputbox(msg3$,msgtitle$) Cls Print " " ;studname$;" "; studsex$;" ";""; studcard$ InputBox Chr$(13)+Chr$(10) InputBox InputBox default InputBox(msg2$,msgtitle$," ") InputBox ImputBox MsgBox Private Sub Form_Click() msgtitle$=" " msg1$="" w=msgbox(msg1$,37,msgtitle$) Print w MsgBox MsgBox msgtitle$msg1$

177 4 Warning Query x For i = 1 To 5 a = a + i Next i x = Val(i) MsgBox x A 4 C 6 B 5 D 7 Msgbox MsgBox (msg [,type] [,title] [,helpfile, context] ) msgtype 0 Title Helpfile Context context helpfile Val C 4 Msgbox A C B D Msgbox Integer 165

178 Visual Basic A x = InputBox(x) y = Len(x) Print "The Length Of "; x; " Is "; y Input Box VB A The Length Of Visual Is 2 B The Length Of Visual Is 3 C The Length Of VB Is 2 D The Length Of VB Is 3 2 a = Val(Text1.Text) If a Mod 3 = 0 Then MsgBox " 3 " Else MsgBox " 3 " End If 126 A 3 B 3 C D 3 a=5 b=6 a = InputBox(" " & "a" & " ") b = InputBox(" " & "b" & " ") 166

179 4 c = a * b + 5 Print c A 6 35 B C TAB(6)35 D 35 4 Sub Form_Load() Dim Password, Pword Password = "Visual" Pword = InputBox("Type in your password") If Pword <> Password Then MsgBox "Sorry, incorrect password" End If A Sorry, incorrect Password B Type in your password Sorry, incorrect password C Type in your password Sorry, incorrect password D Type in your password Visual Sorry, incorrect Password 1 S= n n = Val( 1 (" ")) s = 0 For i = 1 To n GoSub m s = s + 1 Print "t="; t, "s="; s Next i Exit Sub 167

180 Visual Basic m: t = 1 For j = 1 To i t = 2 Next j Return 2 m = Val ( InputBox ( " " ) ) S = 0 N = 0 Do N = N + 1 S = S + 2 ^ N Loop While S <= m Print "N="; N, "S="; S InputBox X = Val(InputBox(" ")) If X > 0 Then Y = X * X Else Y = -X * X End If Print "Y="; Y InputBox Dim X As Integer Dim A(5) As Integer For X = 0 To 4 168

181 4 A(X) = 5 Next X Dim B(5) As String For X = 0 To 4 B(X) = "hello" Next X Dim arrx(2) As Variant arrx(1) = A() arrx(2) = B() MsgBox arrx(1)(2) MsgBox arrx(2)(3) MsgBox arrx(1)(2) 1 MsgBox arrx(2)(3) Visual Basic ActiveX ActiveX Visual Basic Action Action Action Action 1 ShowOpen 2 ShowSave 3 ShowColor 4 ShowFont 5 ShowPrinter 6 ShowHelp Windows 169

182 Visual Basic Name CommonDialogx x Properties / 4.4 DialogTitle FileName InitDir Filter Flags DefaultExt Text Files(*.TXT) *.txt MaxFileSize 1~2K 260 FilterIndex ShowOpen.ShowOpen 170

183 4 2 ShowSave.ShowSave 3. Visual Basic Properties Color Flags ShowColor.ShowColor 4. Visual Basic 171

184 Visual Basic Properties Color FontName FontSize Max Min Flags Style (FontBold) (FontItalic) (FontUnderline) (FontStrikethru) ShowFont.ShowFont 5. Visual Basic Properties 172

185 Copies Flags Orientation Max Min Flags Frompage Topage ShowPrinter.ShowPrinter 6. Visual Basic Windows Properties

186 Visual Basic HelpContext HelpCommand HelpKey HelpFile ID ShowHelp.ShowHelp CommonDialog A ShowOpen B ShowOpen C ShowOpen D ShowOpen ShowSave ShowClose ShowOut ShowClose ShowColor ShowColor ShowSave ShowFont ShowPrinter ShowPrinter ShowPrinter ShowPrinter ShowHelp ShowHelp ShowHelp ShowHelp ShowFont ShowFont ShowFont ShowColor ShowOpen ShowSave ShowColor ShowFont ShowPrinter ShowHelp Windows A 174

187 4 2 A Frompage B Topage C Startpage D Endpage Visual Basic Frompage Topage Startpage Endpage A 3 Visual Basic ShowPrinter 4 1 Name 2 x Action Name CommonDialogx x Action 2 CommonDialogx CommonDialog A ShowOpen B ShowClose C ShowSave D ShowPrinter 2 Action 1 A ShowFont B ShowHelp C ShowOpen D ShowSave 3 A Max B Min C Frompage D Topage 4 A Max B Min C Copies D Pages 5 A CommonDialog1.ShowFont 175

188 Visual Basic B FileTitle C FileName D 6 A CommonDialog1.Filter=All Files *.* Pictures(*.Bmp) *.Bmp B CommonDialog1.Filter="All Files" "*.*" "Pictures(*.Bmp)" "*.Bmp" C CommonDialog1.Filter="All Files *.* Pictures(*.Bmp) *.Bmp" D CommonDialog1.Filter={All Files *.* Pictures(*.Bmp) *.Bmp} 7 A BorderStyle ControlBox MaxButton MinButton 1 True False B frmabout.show vbmodeless frmmain frmabout frmmain C D frmabout.show frmabout 1 CommonDialog1 CommonDialog1.Action=3 2 3 Microsoft Windows CommonControl ToolBar StatusBar 2 TreeView ListView ImageList 3 ImageCombo 4.4 Visual Basic 1 Print Print Space$ n Spc Tab n 2 Format$ 3 Visual Basic FontName FontSize FontBold FontItalic FontUnderline FontStrikethru 4 Visual Basic Printer 176

189 4 Print Visual Basic PrintForm 5 Visual Basic ActiveX ActiveX Action Name CommonDialogx x InputBox() A B C D 2 X = 0 Do Until X = -1 A = InputBox(" A ") A = Val(A) B = InputBox(" B ") B = Val(B) X = InputBox(" X ") X = Val(X) A = A + B + X Loop Print A A 2 B 3 C 14 D

190 Visual Basic a = Val(Text1.Text) If a Mod 2 = 0 Then MsgBox " " Else MsgBox " " End If 50 A B C D 4 k = 1 For j = 1 To 4 k = k * j Next j MsgBox k \ j A 4.8 B 4 C 5 D CommonDialog A ShowOpen B ShowClose C ShowColor D ShowPrinter 6 A B C D 1 A = Val(InputBox(" ")) B = Val(InputBox(" ")) X = A + B 178

191 4 If A > B Then X = A - B Text1.Text = X InputBox Command1 InputBox k = 1 For j = 1 To 5 k = k * j Next j MsgBox k / j 3 BB$ = "Visual Basic 6.0" m = Len(BB$) For j = 1 To m B$ = Mid$(BB$, j, 1) If B$ = "a" Then X = X + 1 Next j MsgBox X 4 N MsgBox n = InputBox(" ") k = Int(Sqr(n)) i = 2 flag = 0 Do While i <= k And flag = 0 If 1 = 0 Then flag = 1 Else 179

192 Visual Basic i = i + 1 End If Loop If 2 Then MsgBox " ", vbokonly, " " Else 3 " ", vbokonly, " " End If 5 InputBox n = InputBox(" ") m = Len(n) For j = 1 dec = dec * 2 + Val( 2 (n, j, 1)) Next j Print ""; dec 6 A = B = 12.3 c$ = "+" d$ = Str$(A) + c$ + Str(B) MsgBox d$ 7 Sum = 0 For j = 1 To 10 If j = 10 Then Else Sum = Sum + j 180

193 4 End If Next j MsgBox Sum 8 m$ = "ABC" n$ = "ABC" k$ = LCase$(m$) j$ = UCase$(n$) MsgBox Asc(k$ + j$) 9 s >= >= = w s w = InputBox(" ") s = InputBox(" ") p = If s >= 200 Then p = 0.7 ElseIf s >= 100 Then p = 0.8 ElseIf s >= 50 Then p = 0.9 End If Print " ="; p * s * w 181

194 Visual Basic 10 K = 0 For J = 1 To 2 For I = 1 To 3 K = I + 1 Next I For I = 1 To 7 K = K + 1 Next I Next J MsgBox I,, "I" MsgBox J,, "J" MsgBox K,, "K" I 1 K 3 J 2 11 A = InputBox(A) B = Len(A) Print "The Length Of "; A; " Is "; B Input Box Visual 12 h = InputBox(" ") h = 1 (h) f = InputBox(" ") f = 2 (f) y = (f - 2 * h) / 2 x = (4 * h - f) / 2 Print " "; x; " "; y; " " 182

195 4 InputBox CommonDialog1 CommonDialog1.ShowColor 183

196 5 1 Sub 2 Sub 3 4 Funtion 5 Funtion Visual Basic Visual Basic Visual Basic Sub Function Visual Basic Sub Click Load Change Visual Basic Visual Basic 5.1 Sub Sub Sub Sub

197 5 [Static][Private][Public] Sub [( )] [Exit Sub] [ ] [Static][Private][Public] Sub _ [( )] [Exit Sub] [ ] [Static][Private][Public] Sub [Form/MDIForm]_ [( )] [Exit Sub] [ ] Sub Sub Sub 1 Static Sub Static Static 0 Static 2 Private Sub 3 Public Sub Public Sub Function _Form/MDIForm _ 185

198 Visual Basic 5 [Optional][ByVal/ByRef][ParamArray] [()] [As ] [= ] Visual Basic Integer Long Single Double String Currency Variant As Variant OptionalOptional ByVal ByRef Visual Basic ParamArray Variant Optional ByVal ByRef Sub Sub Exit Sub Sub GoTo Sub 2. Sub Sub Sub

199 vbtest 5-4 Sub EndSub 2 Sub vbtest2( ) 187

200 Visual Basic Sub vbtest2() 5-4 Sub

201 5 3 Sub Sub vbtest3() Sub vbtest3() 3. Sub Sub Sub Sub Call 1 Call Sub Call [ ( ) ] Call Visual Basic Sub Call Sub 189

202 Visual Basic Call vbtest1(a,b) 2 [ ] Sub Call Sub Call vbtest1 a,b 4. Sub Sub Name _ Form/MDIForm _ Sub ( ) Sub Function Visual Basic Visual Basic 2 1 Visual Basic Visual Basic Sub Function 1 Sub 2 Function 2 Visual Basic Sub 1 2 Visual Basic Sub Click Load Change 190

203 5 Visual Basic Visual Basic 1 2 Visual Basic Sub Visual Basic Sub Call Visual Basic Sub Call Call 5 Sub A Static B Private C Public D Defaut Static Sub Static 0 Private Sub Public Sub A 6 Sub A ByVal B ByRef C ParamArray D Optional ByVal ByRef ParamArray Variant Optional Optional A 191

204 Visual Basic Visual Basic A B C D 2 A B C D 3 Sub A Show B Select C GoTo D Return 4 Sub A abc 3,5 B abc(3,5) C Call abc(3,5) D Call abc() 5 Sub A ByVal B ByRef C ParamArray D Optional 6 Sub A Sub B Sub C Sub D GoTo Sub 7 Sub Sub S1(x As Single, y As Single) t = x x = t/y y = t Mod y Dim a As Single Dim b As Single a=9 192

205 5 b=4 Call S1 (a,b) Print a,b A 9 4 B 2 1 C D Sub subp(b() As Integer) For i = 1 To 4 b(i) = 2 * i Next i Dim a(1 To 4) As Integer a(1) = 5 a(2) = 6 a(3) = 7 a(4) = 8 Call subp(a) For i = 1 To 4 Print a(i) Next i A 2 B 5 C 2 D Private Sub test(p, m, n) p = p + 1: m = m + 1: n = n + 1 Print "sub "; p; m; n a = 1: b = 2: c = 3 193

206 Visual Basic Call test(a, b + 3, (c)) Print "main:"; a; b; c A sub:2 6 4 B sub:2 6 4 main:2 6 4 main:1 6 4 C sub:2 6 4 D sub:2 6 4 main:1 2 3 main: Private Sub f(k, s) s = 1 For j = 1 To k s = s * j Next j Sum = 0 For i = 1 To 3 Call f(i, s) Sum = Sum + s Next i Print Sum A 0 B 3 C 6 D 9 11 Sub test(x,y) y = 1 For i = 1 To x y = y + i Next i m = 0 : n = 4 For i = 1 To n Call test(i,y) m = m + y 194

207 5 Next i Text1.Text = "m=" & m A m=6 B m=13 C m=24 D m=40 12 Dim a(5) As Integer, b(5) As Integer For i = 1 To 5 a(i) = i * i Next i Call ArrayCopy(a(), b()) Print a(5); b(5) Sub ArrayCopy(oldCopy() As Integer, newcopy() As Integer) Dim i As Integer For i = LBound(oldCopy) To UBound(oldCopy) newcopy(i) = oldcopy(i) Next i A 0 25 B 25 0 C 5 5 D Sub Visual Basic Sub Call test(12.3, 6.7) Sub test(x%, y%) 195

208 Visual Basic x% = x% * 2 y% = y% \ 2 Print x%; y% 4 Sub f(k, s) s = 1 For m = 1 To k s = s * m Next m total = 0 For k = 2 To 4 Call f(k, s) total = total + s Next k MsgBox total 5.2 Function Visual Basic Sub Function Sub Function 1. Function 196 [Static] [Private/Public] Function [( )] [As ] [ ]

209 5 [ = ] [Exit Function] [ ] [ = ] End Function Function Function End Function Sub Static Private Public Sub Exit Function As Function Integer Long Single Double Currency String Variant Function = = 0 2. Function Function Sub Sub Function 3. Function Function Visual Basic = Function Visual Basic Sub Function Sub 2 Function 3 Variant 2 Function A Function Function End Function 197

210 Visual Basic B Exit C D Visual Basic Function Function End Function Exit Function B Function Function F(a As Integer, b As Integer) Static c c = a + b F = c End Function Dim a As Integer, b As Integer a = 1: b = 10 For i = 1 To 3 a = a + i Print F(a, b); Next i A B C D Function A Function Function End Function B C Function D Function Variant Function F(a As Integer) Static c

211 5 b = b + 1 c = c + 1 F = a + b + c End Function Dim a As Integer a = 2 For I = 1 To 3 Print F(a) Next I A 4 B 4 C 4 D Function A Exit Function B Exit C Return D Resume 5 Text Command1 Click Private Function even(x As Long) As Boolean If x Mod 2 = 0 Then even = True Else even = False End If End Function Dim n As Long n = Val(Text1.Text) p = IIf(even(n), " ", " ") Label1.Caption = n & " " & p Text1.SelStart = 0 Text1.SelLength = Len(Text1.Text) 23 A 23 B

212 Visual Basic C 23 D 0 6 Private Function fee(x) If x > 1000 Then y = (x ) * 0.05 Else y = 0 End If fee = y End Function x = InputBox("") pay = fee(x) MsgBox " " & pay & " " A 0 B 15 C 25 D 50 7 Function A Exit Sub B Exit Function C End D End Function 8 Function FF(n) x = n * n FF = x End Function For k = 8 To 10 y = FF(k) Print y; Next k A B C D 200

213 5 1 Function F1(a As Integer) Static c c = c + a F1 = c End Function Function F2(a As Integer) Dim c As Integer c = c + a F2 = c End Function Dim a As Integer a = 1 For i = 1 To 3 Print F1(a); F2(a) Next i nd Sub 2 Function fun(n) As Integer If n > 0 Then fun = n * fun(n - 1) Else fun = 1 End If End Function Dim a As Integer For i = 4 To 5 a = fun(i) Print a; Next i 3 201

214 Visual Basic Function fun(byval num As Long) As Long Dim k As Long k = 1 num = Abs(num) Do While num k = k * (num Mod 10) num = num \ 10 Loop fun = k End Function Dim n As Long Dim r As Long n = CLng(InputBox(" ")) r = fun(n) Print r 25 4 Function Fun(a As Integer) Static c c = c + 1 Fun = a + c End Function Dim a As Integer a = 10 For i = 1 To 3 Print Fun(a); Next i 5 Private Function fun(n) As String If n > 0 Then fun = " 0" ElseIf n = 0 Then 202

215 5 fun = " 0" Else fun = " 0" End If End Function Dim c As String For i = -1 To 1 c = fun(i) Print i & c & ";"; Next i Sub Function Sub Function x$ x As String x As String * 6 a() Sub Function Sub Function x As String *6 203

216 Visual Basic Sub vbtest1(a As Integer, b() As Single, c1 As String, d As Long ) Call vbtest1( 26, aa(), "this", ) 2. Visual Basic Sub Function Visual Basic ByVal Sub vbtest2(byval x As Integer,ByVal y As Integer) Print " x=";x;" y=";y x=x+y Print " x=";x;" y=";y Sub Form_Click() Dim a As Integer, b As Integer a=5:b=6 Print " a=";a;" b=";b Call vbtest2(a,b) Print " a=";a;" b=";b x y ByVal x y Visual Basic x y a b 5 6 x y x=x+y x 11 a

217 5 5-7 Sub vbtest2(x As Integer, y As Integer) Print " x=";x;" y=";y x=x+y Print " x=";x;" y=";y Sub Form_Click() Dim a As Integer, b As Integer a=5:b=6 Print " a=";a;" b=";b Call vbtest2((a),(b)) Print " a=";a;" b=";b a b Visual Basic Sub Function Sub vbtest2(x As Integer, y As Integer) Print " x=";x;" y=";y x=x+y Print " x=";x;" y=";y Sub Form_Click() Dim a As Integer, b As Integer 205

218 Visual Basic a=5:b=6 Print " a=";a;" Call vbtest2(a,b) Print " a=";a;" b=";b b=";b x y ByRef a b x y a x b y x=x+y x 11 a Visual Basic Sub ArrayTest1(a() As Integer, b() As Integer)... Sub Form_Click()... Dim m() As Integer, n() As Integer... Call ArrayTest1 (m(),n())... Call ArrayTest1 m n a b Visual Basic ArrayTest1 m n a m b n 206

219 5 LBound UBound LBound UBound 4. Visual Basic 6.0 Visual Basic 6.0 Optional Optional Optional IsMissing IsMissing Optional IsMissing Boolean IsMissing True False Sub vbtest4(x As Integer, y As Integer,Optional z) x=x+y If Not IsMissing(z) Then x=x+z End If Print x Private Sub Form_Click() vbtest4 5,6,10 x y Integer z Variant z Optional vbtest4 x y x Not IsMissing(z) z z x x Form_Click 21 Form_Click vbtest4 5,6,10 207

220 Visual Basic Private Sub Form_Click() vbtest4 5,6 Not IsMissing(z) z 11 Variant Visual Basic 6.0 ParamArray Sub (ParamArray ) Variant Sub vbtest4(paramarray Numbers()) n=0 For Each x In Numbers n=n+x Next x Print n Private Sub Form_Click() vbtest4 5,6, Visual Basic Sub ( ) [Exit Sub] 208

221 5 Form Control Visual Basic Visual Basic Visual Basic Visual Basic 1 2 Visual Basic Visual Basic A LBound B UBound C D Visual Basic LBound UBound LBound UBound D 209

222 Visual Basic 5 Sub abc(x, y) x = 2 * x y = 3 * y Print "x="; x; ",y="; y Private Sub Form_Click() a = 1: b = 1 1: Print "a="; a; ",b="; b Call abc((a), b) 2: Print "a="; a; ",b="; b Visual Basic Sub Function Form_Click a b 1 1 Print a=1,b=1call abc((a), b)a b a (a) abc (a) b abc x (a) 1 y b x 2 y 3 Print x=2,y=3 abc y b b 3 a 1 2 Print a=1,b=3 a=1,b=1 x=2,y=3 a=1,b= Visual Basic 210

223 5 A B C D 2 Visual Basic A B Visual Basic C ByVal D 3 a Dim a Sub test() a = a + 1: b = b + 1: c = c + 1 Print "Sub"; a; b; c Private Sub Form_Click() a = 2: b = 3: c = 4 Call test Print "main:"; a; b; c A Sub:3 4 5 B Sub:2 3 4 Main:3 4 5 Main:1 2 3 C Sub:4 1 1 D Sub:3 1 1 Main:4 3 4 Main: Visual Basic A Sub B Function C Property D Private 1 Visual Basic 1 ByVal 2 211

224 Visual Basic 2 Sub vbtest2(byval x As Integer,ByVal y As Integer) Print " x=";x;" y=";y x=x+y Print " x=";x;" y=";y Sub Form_Click() Dim a As Integer, b As Integer a=5:b=6 Print " a=";a;" b=";b Call Print " a=";a;" b=";b vbtest Visual Basic Visual Basic Visual Basic KeyDown KeyUp KeyPress Sub _KeyDown ( KeyCode As Integer, Shift As Integer) Sub _KeyUp ( KeyCode As Integer, Shift As Integer ) 212

225 5 Sub _KeyPress ( KeyAscii As Integer) 1 KeyDown KeyUp KeyPress KeyDown KeyPress KeyUp KeyDown KeyUp KeyPress ASCII A KeyDown KeyCode A a KeyCode KeyPress KeyAscii ASCII A ASCII 65 a ASCII 97 KeyAscii KeyDown KeyCode Shift 2 KeyAscii ASCII KeyCode ASCII KeyCode ASCII KeyCode KeyCode ASCII 5.1 KeyCode KeyAscii 5.1 KeyCode KeyAscii KeyCode KeyAscii A &H41 &H41 a &H41 &H61 B &H42 &H42 b &H42 &H62 % &H35 &H25 0 &H30 &H30 9 &H39 &H39 0 &H60 &H30 9 &H69 &H39 213

226 Visual Basic Shift 3 Shift Ctrl Alt 3 Shift 001 Ctrl 010 Alt 100 Shift Shift Ctrl Shift Alt Shift Shift Shift Shift Shift Ctrl Ctrl +Shift Alt Alt +Shift Alt +Ctrl Alt +Ctrl +Shift 3 KeyDown KeyUp KeyPress 4 KeyDown KeyUp KeyPress KeyPreview True False 2. ClickDblClick Visual Basic MouseDown MouseUp MouseMove Sub _MouseDown(Button As Integer,Shift As Integer,x As Single,y As Single) Sub _MouseUp(Button As Integer,Shift As Integer,x As Single,y As Single) Sub _MouseMove(Buaon As Integer,Shift As Integer,x As Single,y As Single) 214

227 5 1 MouseDown MouseUp MouseMove 2 Button (16 ) Button LEFT BUTTON RIGHT BUTTON IDDLE BUTTON MouseDown MouseUp Button MouseMove Button Shift Shift Ctrl Alt Shift x y 3. Windows Visual Basic MousePointer MousePointer 0~

228 Visual Basic 5.4 MousePointer vbdefault 0 vbarrow 1 vbcrosshair 2 vbibeam 3 I vbiconpointer 4 vbsizepointer 5 4 vbsizenesw 6 vbsizens 7 vbsizenwse 8 vbsizewe 9 vbuparrow 10 vbhourglass 11 vbnodrop 12 vbarrowhourglass 13 vbarrowquestion 14 vbsizeall 15 vbcustom 99 MouseIcon MousePointer MousePointer MousePointer 5-9 MousePointer 5-9 MousePointer 216

229 5 MousePointer.MousePointer = MousePointer MousePointer 99 MouseIcon 4. Dragging Dropping Visual Basic 5.5 Visual Basic 5.5 DragMode 0-Manual DragIcon DragMode 1-Automatic DragDown Drag DragIcon DragOver DragOver DragOver DragDrop DragOver DragDrop 1 DragMode 0-Manual DrogMode 1-Automatic DrogMode 5-10.DragMode = 1.DragMode = 0 2 DragIcon DragIcon DragIcon 5-11.DragIcon = LoadPicture ( " ") 217

230 Visual Basic 5-10 DragMode 3 DragOver DragOver Sub _DragOver ( Source As Control, x As Single, y As Single, State As Integer ) Source Control x y State State DragDrop DragDrop Sub _DragDrop ( Source As Control, x As Single, y As Single ) EndSub 218

231 5 Source Control x y 5 Drag Drag Drag.Drag Drag 0 1 Drag 2 DragDrop Visual Basic ASCII A KeyDown B KeyUp C KeyPress D KeyAscii KeyDown KeyUp KeyPress ASCII KeyAscii C 2 Visual Basic Visual Basic MouseDown MouseUp MouseMove MouseDown MouseUp MouseMove 1 MouseDown 2 MouseUp 3 MouseMove 3 Visual Basic 1 2 Dragging Dropping Visual Basic

232 Visual Basic 4 Visual Basic A DragMode B Drag C DragDrop D DragOver DragMode Drag DragDrop DragOver B Visual Basic A KeyDown B KeyUp C KeyPress D KeyAscii 2 Visual Basic A MouseDown B MouseMove C MouseUp D MousePointer 3 Visual Basic 55 KeyCode KeyAscii A B C D 4 A DragMode B Drag C DragDrop D DragOver 5 DrogMode A 1 B 0 C 1 D 2 6 Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button=2 Then Print "AAAAA" End If 220

233 5 Private Sub Form_MouseUp(Button As Integer,Shift As Integer,X As Single,Y As Single) Print BBBBB A AAAAA B BBBBB BBBBB AAAAA BBBBB BBBBB C AAAAA D BBBBB BBBBB BBBBB 7 Option Base 1 Private Sub Form_KeyPress(KeyAscii As Integer) a = Array(200, 50, 450, 500, 230,800) m1 = a(1) m2 = 1 If KeyAscii = 13 Then For i = 2 To 6 If a(i) > m1 Then m1 = a(i) m2 = i End If Next i End If Print m1 Print m2 A 200 B 200 C 50 D Private Sub Text1_KeyPress(KeyAscii As Integer) Char = Chr(KeyAscii) 221

234 Visual Basic KeyAscii = Asc(UCase(Char)) 2 Visual Basic Visual Basic Visual Basic 5.5 Visual Basic 1 Visual Basic 2 Visual Basic Sub Function Sub Function 3 Visual Basic 4 Click Load Change VisualBasic 5 Sub Sub Call 6 Sub Sub Name _ Form/MDIForm _ 7 Sub Function 222

235 5 8 Function Function End Function Function Visual Basic 9 Visual Basic 10 Visual Basic 6.0 Optional Optional IsMissing ParamArray 11 Visual Basic KeyDown KeyUp KeyPress KeyDown KeyUp KeyPress ASCII 12 Visual Basic MouseDown MouseUp MouseMove MouseDown MouseUp MouseMove 13 Visual Basic MousePointer 14 Dragging Dropping Visual Basic DragMode DragIcon Drag DragDrop DragOver 223

236 Visual Basic Visual Basic A LBound B UBound C D 2 Visual Basic A KeyDown B KeyUp C KeyPress D KeyAscii 3 Sub A Static B Private C Public D Defaut 4 Function abc(n) As Integer For i=1 To 3 n = n + i Next i abc= n End Function Dim a As Integer a = 5 Print abc(a*a) A 25 B 28 C 31 D

237 5 5 Visual Basic A MouseDown B MouseMove C MouseUp D MousePointer 6 A DragMode B Drag C DragDrop D DragOver 7 Function F1(a As Integer) Static c c = c + a F1 = c End Function Function F2(a As Integer) Dim c As Integer c = c + a F2 = c End Function Dim i As Integer For i = 1 To 3 Print F2(F1(i)) ; Next i A B C D Visual Basic A MouseDown B MouseMove C MouseUp D MousePointer 9 Text1.Text = UCase(Text1.Text) Private Sub Command2_Click() Text1.Text = LCase(Text1.Text) Private Sub Command3_Click() 225

238 Visual Basic Text1.Text = Text1.Tag Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer) Text1.Tag = Text1.Text Abc Command1 Command2 Command3 A ABC abc ABC B ABC abc Abc C abc ABC Abc D abc ABC abc 10 Sub test(x%, y%, z%) z% = x% + y% a% = 12.5: b% = 40.2 Call test(a%, b%, c%) Print c% A 0 B 52 C 53 D 11 Sub Sub test(x As Single, y As Single) t = x x = t + 2 y = t - 2 Dim a As Single Dim b As Single a = 10 b = 4 226

239 5 Call test(a, b) Print a, b A 12 8 B 10 4 C 8 6 D Sub test(b() As Integer) For i = 1 To 4 b(i) = 2 * i Next i Private Sub Form_Click() Dim a(1 To 4) As Integer For i = 1 To 4 a(i) = i Print a(i); Next i Print test a For i = 1 To 4 Print a(i); Next i Function Fee(x) If x <=20 Then y = x Else y = 20 + x End If 227

240 Visual Basic Fee = y End Function x = InputBox("",, 0) pay = Fee(x) Print pay x 20 1 x n Function Fun(t) p = 1 For j = 1 To t p = p * j Next j 1 End Function s = 0: c = "1 " n = Val(InputBox(" :")) For t = 1 To n s = s + 2 Next t For i = 2 To n c = c & "+" & i & " " Next i c = c & "=" Print c; s 4 Dim a(5) As Integer, b(5) As Integer For i = 1 To 5 a(i) = i * i Next i Call ByteCopy(a(), b()) 228

241 5 Print "a(5)=" & a(5) & ";b(5)=" & b(5) Sub ByteCopy(oldCopy() As Integer, newcopy() As Integer) Dim i As Integer For i = LBound(oldCopy) To UBound(oldCopy) newcopy(i) = oldcopy(i) Next i 5 Function Fun(a As Integer) Static c b = b + 1 c = c Fun = a + b + c End Function Dim a As Integer a = 1 For i = 1 To 3 Print Fun(a); Next i 6 Sub 7 Dim a As Integer, b As Integer, c As Integer a = 10: b = 2: c = 3 Print c; Call sub1 Print c; Call sub2 Print c Sub sub1() 229

242 Visual Basic c = a * b Sub sub2() c = a / b 8 Private Function fun(n) As Integer If n > 0 Then fun = n * fun(n - 1) Else fun = 1 End If End Function Dim a As Integer For i = 3 To 4 a = fun(i) Print a, Next i 9 Function Fun(a As Integer) Static c c = c * / 4 Fun = a + c End Function Dim a As Integer a = 10 For i = 1 To 2 Print Fun(a); Next i 230

243 Visual Basic 5 Sub Main 6 DoEvents Load Load Load Form_Load Load Name 2 Unload Unload Load Form_QueryUnload 3 Show

244 Visual Basic [. ] Show [ ] Show Show Show vbmodal 0 4 Hide [. ] Hide Hide Hide Unload Unload Name Caption StartUpForm Form Label

245 Name StartUpForm Caption BorderStyle 1-Fixed Single Enabled True Visible True Height 4200 Width 5200 Top 0 Left 0 MaxButton False MinButton False ControlBox False MDIChild False MDI MDI StartUpPosition 2-CenterScreen 6.3 Name Label1 Caption Alignment 2-Center Font 233

246 Visual Basic ForeColor &H & Height 855 Width 3650 Top 1080 Left Name MainForm Caption BorderStyle 2-Sizable Enabled True Visible True Height 3600 Width 4800 Top 0 Left 0 MaxButton True MinButton True ControlBox True MDIChild False MDI MDI StartUpPosition 3-Default 234

247 Name Caption FontSize FontName Name Caption FontSize FontName Name Caption FontSize FontName Name Caption FontSize FontName ForeColor Name Text FontSize FontName Name Caption FontSize FontName Name Caption FontSize FontName Lbl1 Lbl2 Lbl3 LblKey Arial &H000000FF& Txt1 Arial CmdCalc CmdEnd

248 Visual Basic 6-3 CmdCalcCmdEnd Click Click Private Sub CmdCalc_Click() LblKey.Caption = Val(Txt1.Text) * Val(Txt1.Text) Private Sub CmdEnd_Click() End Click Private Sub Form_Click() MainForm.Show Unload StartUpForm MainForm.Show Show MainForm Unload StartUpForm Unload Hide Private Sub Form_Click() 236

249 6 MainForm.Show If StartUpForm.Visible Then StartUpForm.Hide End If Hide StartUpForm Load Initialize Load Unload QueryUnload Unload Set = Nothing Terminate Initialize Initialize Set = Nothing Load Initialize Unload Load Initialize Load A Load B Load Form_Load C D Load Load Form_Load Load D 3 A Load Form_Load B Unload Form_QueryUnload C Show 237

250 Visual Basic D Load Load Form_Load Unload Form_QueryUnload Show Show Show C 4StartUpForm Form_Click StartUpForm MainForm MainForm StartUpForm Private Sub Form_Click() MainForm. 1 If StartUpForm. StartUpForm. End If 2 Then 3 StartUpForm Form_Click Show MainForm Hide StartUpForm Visible Visible 1 Show 2 Visible 3 Hide A Hide B Show C Load D Unload 2 A Hide B Show C Load D Unload 3 Show A Show B Show C Show D Show 238

251 6 4 A Enabled B BorderStyle C Height D Width 1 Visual Basic Visual Basic 6.0 3Form_ClickStartUpForm MainForm MainForm StartUpForm Private Sub Form_Click() MainForm. 1 2 StartUpForm 4 Name Form1 Form2 Form1 Form1 Command1 Form1 Form2 Private Sub Command1 Click() 1 Form

252 Visual Basic Visual Basic

253 Visual Basic StartUpForm 6-6 StartUpForm.frm.bas vbp 1.vbp 2 241

254 Visual Basic 3 Visual Basic.exe 6-6 XX.exeXX 6-6 vb1.vbp vb1.exe vb1.exe Windows Visual Basic 6.0 Visual Basic Visual Basic Visual Basic Visual Basic A.frm B.vbp C.bas D.cls Visual Basic 6.0.frm.bas.cls.vbp B 242

255 A.frm B.vbp C.bas D.cls 2 A.frm B.vbp C.bas D.cls 3 A B C D Visual Basic 1 Visual Basic Visual Basic 6.3 Visual Basic Visual Basic Module Visual Basic 3 1..bas 243

256 Visual Basic Public Dim Private

257 6 2. Visual Basic.frm Dim Public. ( ) 3. Sub Main Visual Basic Sub Main Sub Main Sub Main Sub Main Sub Main

258 Visual Basic Visual Basic Sub Main Visual Basic Sub Main Sub Main Sub Main 4. DoEvents Visual Basic Windows Visual Basic Windows Visual Basic DoEvents Windows DoEvents DoEvents [ = ] DoEvents [ ( ) ] DoEvents Visual Basic Module Visual Basic bas Public 3 4 Dim Private frm

259 6 Visual Basic Visual Basic Sub Main Sub Main Sub Main Sub Main A B Sub Main C D 2 A B Sub Main C D Public 3 A B C D 4 A B C D 5 Sub Main A B Sub Main C Visual Basic Sub Main D Sub Main 247

260 Visual Basic Visual Basic 4 Visual Basic Load Form_Load Unload Form_QueryUnload Show Hide 3 Visual Basic.vbp.bas.frm.cls.vbg 4 5 Visual Basic 6 Visual Basic.exe 7 Public 248

261 6 8 Dim Private 9 Sub Main Sub Main Sub Main Visual Basic Sub Main 10 Visual Basic Visual Basic DoEvents Visual Basic A B Sub Main C Load D 2 A Hide B Show C Load D Unload 3 A B C Visual Basic D 4 Load A Load B Load Form_Load C Load D 5 A Load Form_Load B Show C Unload Form_QueryUnload 249

262 Visual Basic D Load 6 Visual Basic 6.0 A B C Sub Main D 7 Visual Basic A.vbp B.frm C.sys D.exe 1Form_ClickStartForm MainForm MainForm StartForm Private Sub Form_Click() 1. Show Unload 2 2 Visual Basic Visual Basic.vbp Command1 Command2 Command1 Command1 Command2 1. Enable = False 2. Enable = True 5 6 Visual Basic Name Form1 Form2 Form1 Form1 Command1 Form1 Form2 250

263 6 Private Sub Command1 Click() 1 Me Form StartUpForm Form_Click StartUpForm MainForm MainForm StartUpForm Private Sub Form_Click() MainForm. 1 If StartUpForm.Visible Then StartUpForm. 2 End If

264 Visual Basic 1 Character 2 Field Record Visual Basic 4 File Sequential File

265 7 Random Access File 2 ASCII ASCII ASCII File ASCII Binary File A C B D Visual Basic Character Field Record File A ASCII 3 Visual Basic 253

266 Visual Basic ASCII ASCII ASCII A B C D 2 A B C D 3 A B C D 4 A B C D

267 Seek Seek 1 Seek Seek #, Seek 1~511 Open 1~ Seek Seek ( ) Seek Seek 1~ FreeFile Fr eefile [ ] FreeFile 0 1~ ~ Loc Loc ( ) Loc / Loc Loc Loc 4. LOF LOF ( ) LOF Open Visual Basic

268 Visual Basic Visual Basic LOF 128 FileLen 5. FileLen FileLen ( ) FileLen ASCII 6. FileAttr FileAttr (, ) FileAttr FileAttr FileAttr 1 Input 2 Output 4 Random 8 Append 32 Binary 7. EOF EOF( ) EOF EOF True False Get True False 8. Lock Unlock Lock [#] [, /[ ] To ] Unlock [#] [, /[ ] To ] Lock Unlock Lock Unlock 256

269 7 1~ A EOF LOF Lock Unlock B LOF EOF Lock Unlock C EOF LOF Unlock Lock D LOF EOF Unlock Lock EOF LOF Lock Unlock A 2 Seek A 1~255 B 1~511 C 1~ D 1~ Seek 1~ D Visual Basic A 255 B 511 C 512 D Visual Basic A Seek B Skip C FreeFile D FileAttr 3 Visual Basic FileLen A B C D 4 Visual Basic A Seek B Skip C FreeFile D FileAttr 257

270 Visual Basic 5 Visual Basic Open A Seek B LOF C Loc D EOF 6 Visual Basic A Seek B LOF C Loc D EOF 7 Visual Basic A 128 B 256 C 512 D EOF 3 Visual Basic 4 FreeFile Visual Basic Open Open [For ] [Access ] [ ] As [#] [ Len = ] Open 258

271 Input Output Append Random Access Access Read Write Read Write Append Open Lock Shared Lock Read Lock Write Lock Read Write Read Write 259

272 Visual Basic [#] 1~511 Open Len= Len 2 Output Append Input Random Binary 3 Open Open 2. Print# Write# 1 Print# Print #,[ [Spc(n) Tab(n)] [] [;,] ] Print # Open Spc(n) Tab(n) Print# Print Print Print# Print # ;, " 260

273 7 Print# Print# Close Print# 2 Write# Write #, Write# Open Print# Write# 3. Input# LineInput# 1 Input# Input #, Open Input# 2 LineInput# LineInput #, 261

274 Visual Basic Open LineInput# Input# Input# LineInput# 3 Input$ Input$ ( n, # ) Input$ n n Open 4. Close Close [ [ # ] ] [, [ # ] ] Close Visual Basic Open Close Close c:\source1.txt 1 c:\source2.txt 2 Open Open 262

275 7 Open [For ] As [#] For 1 Open "c:\source1.txt" For Input As #1 2 Open "c:\source2.txt" For Output As #2 2 Visual Basic #6 Print # Print Print #,[ [Spc(n) Tab(n)] [] [;,] ] # 1~511 Spc(n) n Tab(n)n Visual Basic 6 # #6 Visual Basic Spc(n) Tab(n) Print #6, Visual Basic Output Append Input Random Binary 1 2 Output Append 3 Input Random Binary LineInput# Input# Input# LineInput# 1 Input# 2 LineInput# 5 A Write #, B Write #,using; C Print #, D Print #,using; Print# Print #,[ [Spc(n) Tab(n)] [] [;,] ] 263

276 Visual Basic Write# Write #, Write Print B 6 A Input # Read# B Read LineInput# C Get# LineInput# D LineInput # Input # Input# LineInput# Get VB Read D 7 A Put C Print B Get D Close Put Get Print Close D A Put B Write C Print D Open 2 A B C D 3 Close A B C 264

277 7 D 4 A Write #2,name$,salary B Write #2, name$;salary C Print #2, name$,salary D Print #2, name$;salary 5 A Input# Read# B Read LineInput# C Get# LineInput# D Input# LineInput# 6 work.dat A Open "work.dat" For Output As #1 B Open "work.dat" For Append As #1 C Open work.dat" For Output As #1 D Open work.dat For Append As #1 7 Open Input A B C D 8 Print #1,str$ Print A B C D 9c:\t1.txt A F="c:\t1.txt" Open F For Input As #1 B F="c:\t1.txt" Open "F" For Input As #1 C Open "c:\t1.txt" For Output As #1 D Open c:\t1.txt For Input As #1 10 c:\t1.txt A F="c:\t1.txt" Open "F" For Append As #2 B F="c:\t1.txt" Open "F" For Output As #2 C Open c:\t1.txt For Output As #2 D Open "c:\t1.txt" For Output As #2 265

278 Visual Basic 1 1 newfile1.dat 2 2 newfile2.dat 3 EOF 1 LOF Write# Input# A sour.dat dest.dat Open "c:\sour.dat" For 1 As #3 Open "c:\dest.dat" For 2 As #2 While 3 Input #3, Name$, eng, phy, Math Write #2, Name$, (eng + phy + Math) / 3 Wend Close #3, #2 6 c:\stud1.txt END Private Sub Form_Load() Open "c:\stud1.txt" For Output As #1 Text1 = "" Private Sub Text1_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then If 1 Then Close #1 End Else 2 Text1 = "" End If 266

279 7 End If 7 C stud1.txt new.txt stud1.txt Dim str1$ Open "c:\stud1.txt" For 1 As #1 Open "c:\new.txt" For Output As 2 Do While Not EOF(1) 3 Print #2, str1 Loop Close 4 5 "c:\stud1.txt " n n 1 1. Type End Type Type End Type Private Type End Type 267

280 Visual Basic 2. Open Open [ For ] As # [ Len = ] Open Open Random Random Len= 128 Open " " For Random As # [Len= ] 3. Put Put #, [ ], Open 1~ Random 4. Get Get #, [ ], Get Put 268

281 A B C D Visual Basic Type End Type C 2 A C B D Type End Type Private C 3 A Type stud B Type stud id As lnteger id As Integer name As String * 10 name As String * 10 score (1 To 4) As Single score() As Single End Type End Type C Type stud D Type stud id As Integer id As Integer name As String * 10 name As String score (1 To 4) As String score (1 To 4)As Single End Type End Type Visual Basic B 269

282 Visual Basic score() C score() D name A A 4 Open "old.txt" For Random As # 1 Len=20. old.txt A 20 B 20 C 20 D 20 Open old.txt Open Open [ For ] As # [ Len = ] Open Random B 5 A Get,, B Get,, C Put,, D Put,, Get Get Put Put D A Type person B Type person no As lnteger no As Integer name As String name As String *

283 7 fee(1 To 12) As Single fee () As Single End Type End Type C Type person D Type person no As Integer no As Integer name As String * 10 name As String * 10 fee (1 To 12) As String fee (1 To 3) As Single End Type End Type 2 Type stud no As lnteger name As String * 10 mark(1 To 3) As Single End Type A Dim s As stud B Dim s As stud stud.no=0301 s.no=0301 stud.name=" " s.name=" " stud.mark=78,88,96 s.mark=78,88,96 C Dim s As stud D Dim s As stud s.no=0301 stud.no=0301 s.name=" " stud.name=" " s.mark(1)=78 stud.mark(1)=78 s.mark(2)=88 stud.mark(2)=88 s.mark(3)=96 stud.mark(3)=96 3 Type stud no As lnteger name As String * 10 mark(1 To 3) As Single End Type 10 Dim s10(1 to 10) As Stud

284 Visual Basic A s10(3).mark(3) s10(3).name B s3.mark(3) s3.name C s10(3).mark s10(3).name D With s10(3).mark.name End With 4 stud.dat stud s A Open stud.dat For Random As #1 Put #1,1,s Close#1 B Open "stud.dat" For Random As #1 Put #1,1,s Close #1 C Open "stud.dat" For Output As #1 Put #1,1,s Close #1 D Open "stud.dat" For Random As #1 Put #1 s Close #1 5 EOF() 1 A B C D 6 1 q.dat 100 A Open "q.dat", For Input Access Read AS#1 LEN=100 B Open "q.dat", For Append Access Read AS#1 LEN=100 C Open "q.dat", For Random AS#1 LEN=100 D Open "q.dat", For Append AS#1 LEN= va A Put #4 va 5 B Put #4 5 va C Get #4 va 5 D Get #4 5 va 8 Open "source.txt" For Random As # 1 source.txt A 128 B 128 C 256 D

285 7 9 c:\file.txt Dim InputData Open "c:\file.txt" For Input As #1 Do While Not EOF(1) Line Input #1, InputData Loop Close #1 MsgBox InputData A B 1 C 100 D 1 F1.DAT Type worker Name As String *10 Pay As Single End Type Dim work1 As worker Open "c:\f1.txt" For Random As #1 Len = Len(work1) work1.name = "LiuMin": work1.pay = Close #1 Open "c:\f1.txt" For Random As #1 Len = Len(work1) 273

286 Visual Basic 2 Print "work1:l"; work1.name Print "work1:l"; work1.pay Close #1 End 2 Open DriveListBox DirListBox FileListBox Visual Basic Visual Basic Drive. Drive [ = ] 274

287 7 7-2 Drive Drive Change Change Drive1 Change Drive1_ Change() Drive Path Path 275

288 Visual Basic [. ]. Path [ = " " ] [. ]. Path[ = " " ] DOS = Path Path Path Change Dir1 Change Dir1_Change() 3. Path 7-4 Path File1 Change File1_Change() Pattern [. ]. Pattern [ = ] Pattern Pattern *.* 276

289 7 Pattern Pattern Pattern Pattern Pattern_Change 2 FileName [. ] [. ] FileName [ = ] FileName Multiselect Archive Hidden Normal ReadOnly System ListCount ListIndex List True False Archive Hidden Normal ReadOnly System 4. Drive_Change Drive Path Dir_Change Path Path Private Sub Drive1_Change() 277

290 Visual Basic Dir1.Path=Drive1.Drive ' Private Sub Dir1_Change() File1.Path=Dir1.Path ' Drive Change Drive1_Change Path Path Change Dir1_Change Path Visual Basic 1 2 FileListBox Visual Basic DriveListBox DirListBox FileListBox 1 DriveListBox 2 DirListBox 2 Drive Visual Basic Drive Change Change Drive1 Change Drive1_Change() Change Visual Basic 278

291 7 Path 1 2 Path 4 1 Change 2 Change 3 Change Visual Basic Drive Change Path Change 1 Drive 2 Path 3 Path 5 Private Sub Drive1_Change() 1 Private Sub Dir1_Change() 2 Drive Change Drive1_Change Dir1.Path Drive1.Drive Path Change Dir1_Change File1.Path Dir1.Path 3 1 Dir1.Path=Drive1.Drive 2 File1.Path=Dir1.Path 6 Visual Basic A List B Multiselect C Pattern D FileName Visual Basic List Multiselect True False Pattern FileName 279

292 Visual Basic C 7 A Drive B Name C Visible D Index Visual Basic Drive Drive Name Visible Index A A Visual Basic Drive Change B Change C D Drive 2 Visual Basic A ReadOnly B Archive C Hidden D System 3 Visual Basic A List B Multiselect C Pattern D FileName 1 FileName 1 Path 2 2 Path Path

293 7 4 Pattern Pattern 1 Pattern (Kill ) Kill Kill ASCII *? kill "c:\vbtest\ *.bak" c:\vbtest.bak 2. (FileCopy ) FileCopy, FileCopy ASCII FileCopy *? Visual Basic FileCopy "source.doc", "d:\vbtest\target.doc" source.doc d:\vbtest target.doc 3. (Name ) Name As 281

294 Visual Basic Name ASCII Name Visual Basic Name 1 Name "oldfile.txt" As "newfile.txt" oldfile.txt newfile.txt 2 Name "c:\vbtest\oldfile.txt" As "c:\vbtest\ex\oldfile.txt" c:\vbtest oldfile.txt c:\vbtest\ex 3 Name "c:\vbtest\oldfile.txt" As "c:\vbtest\ex \newfile.txt" c:\vbtest oldfile.txt c:\vbtest\ex newfile.txt 4 Name "c:\vbtest" As "c:\vbtestnew" c:\vbtest c:\vbtestnew 4. Shell Shell ( [, ] ) Shell ASCII vbhide 0 vbnormalfocus 1 282

295 7 vbminimizefocus 2 vbmaximizefocus 3 vbnormalnofocus 4 vbminimizenofocus DriveListBox DirListBox FileListBox 3 Kill DriveListBox DirListBox FileListBox Kill File1.Path File1.FileName File1.Path + "\" + File1.FileName 2 file1.copy param1, param2 A file1 File Folder B param1 C param1 D param2 param1 parame2 True False True B 3 FileCopy A B C *? D Visual Basic FileCopy 283

296 Visual Basic FileCopy FileCopy ASCII FileCopy *? Visual Basic C Kill VB A B C D 2 Name A Name B C D Visual Basic 3 Shell A Shell B C vbhide D vbhide 4 file1.copy param1, param2 A file1 File Folder B param1 C param1 D param2 5 Sub ShowFileInfo(filespec) Dim fs f,s Set fs =CreateObject( Scripting.FileSystemObject ) Set f =fs.getfile(filespec) s=f.datecreated MsgBox s 284

297 7 A filespec B C D 1 C vbtest 2 d:\vbtest source.doc target.doc 3 c:\vbtest oldfile.txt c:\vbtest\ex 4 c:\vbtest c:\vbtestnew 5 c:\vbtest run.exe 7.7 Visual Basic 1 Visual Basic CharacterField Record File 2 Sequential File Random Access File ASCII ASCII File Binary File 3 Seek Seek FreeFile Loc / LOF Open 285

298 Visual Basic FileLen FileAttr EOF Lock Unlock 4 Visual Basic Open Print# Write# Input# LineInput# Close 5 Type End Type Open Put Get 6 DriveListBox DirListBox FileListBox 7 Kill FileCopy Name Shell Visual Basic A Add B AddItem C AddString D AddObject 2 286

299 7 Dim fs As New FilesystemObject,f As File C text.txt A f=fs.get File("c:\text.txt") B Set f=fs.get File("c:\text.txt") C f=fs.getfile("text.txt") D Set f=fs.getfile("text.txt") 3 A B ASCII C D 4 A B C ASCII D 5 A B C D 6 Visual Basic A Archive B ReadOnly C Hidden D System 7 A Write # 1, math,eng B Write # 1, math;eng C Print # 1,math,eng D Print # 1, math;eng 8 FileCopy A B C *? D Visual Basic 9 A Input # B Read # C LineInput # D Get # 10 Open "old.txt" For Random As # 1 Len=50.old.txt A 50 B 50 C 50 D Visual Basic A List B Multiselect 287

300 Visual Basic C Pattern 12 D FileName Type Student no As Integer name As String * 10 score(1 To 4) As Integer End Type Dim stu1 As Student A B C D 13 A Put,, B Put,, C Get,, D Get,, 1 c:\vbtest oldfile.txt c:\vbtest\ex newfile.txt 2 Visual Basic Private Sub Drive1_Change() 1 Private Sub Dir1_Change() 2 4 FileCopy 1 *? 2 Visual Basic d:\vbtest old.doc new.doc 3 288

301 7 5 Visual Basic 6 Visual Basic 7 Visual Basic Visual Basic 1 2 Open Visual Basic Drive

302 A 1. Visual Basic 2. Visual Basic Visual Basic Visual Basic 1 Visual Basic 2 Visual Basic Visual Basic

303 A Print 2 Print Tab Spc Space $ 3 Format $ 2 InputBox 3 MsgBox MsgBox

304 Visual Basic Tab IIf 2 3 For 4 5 Do 6 7 GoTo 1 GoTo 2 On-GoTo ForEach Next Sub 1 Sub 2 Sub 3 2 Funtion 292

305 A 1 Funtion 2 Funtion Visual Basic SubMain 4 DoEvents 1 KeyPress 2 KeyDown KeyUp

306 Visual Basic

307 B 2 Visual Basic C 2 A 3 A 4 D 5 D 6 B 7 C 8 B 9 C 10 D 11 B 12 C 13 D 14 D 15 B 16 A 17 C 18 B 19 A 20 D Hide 2 Show D 2 A 3 C 4 C 5 A 6 C 7 C 8 D 9 A 10 B 11 A 12 C 13 A 14 C 15 A 16 D 17 B 18 A 19 A 20 B 21 B

308 Visual Basic SetFocus 2 Text Min 3 Max 4 Tab Command1.Enabled=True 2 Command1.Enabled=False A 2 D 3 A 4 A 5 B 6 C 7 C 8 C 9 C Visual Basic C 2 A 3 B 4 C 5 B 6 B 296

309 B 1 1.frm 2.vbp Debug.Print D 2 B 3 A 4 C 5 B 6 B 7 B 8 D 9 B 10 C 11 A 12 C 13 B As Single 2 As Date 7 a b= End Type A 2 D 3 B 4 B 5 C 6 B 7 B 8 B 9 C 10 A 1 1 Dim Static 2 Dim Private 3 Public Global 2 Option Explicit Dim 2 Static 5 1 # 2 $ 3 % 297

310 Visual Basic C 2 B 3 C 4 B 5 D 6 A 7 D 8 C 9 D 10 A 11 B 12 C 13 C 14 B 15 A 16 C 17 D 18 A 19 C 20 B (2*x^3+LOG(Abx(X 1))/2) Good evening! 8 INT(100*x+0.5)/100 9 a 10 2*(1+Log(3*X)) 11 "xyz123abc" 12 True a b 14 2 x (1 + x e ) D 2 B 3 B 4 B 5 A 6 D 7 C 8 D 9 C 10 B 11 C 12 C 13 A 14 C 15 D 16 C 17 B 18 A 19 C 20 C 21 D 22 A 23 C 24 C 25 A 298

311 B 26 A 1 2 CBC Int((Rnd * 6) + 1) 10 This is a book A 2 B 3 B 4 A 5 B 6 B 7 B 8 B 9 B 10 A 11 B 12 C 13 B 14 D 15 B Good x < B 2 A 3 A 4 A 5 D 299

312 Visual Basic 6 C 7 B 8 C 9 D 10 B 11 A 1 Tab(3*j) 2 1 "000,000.00" 2 "###,###.##" 3 1 : 2 ; 3, C 2 A 3 D 4 D 1 1 InputBox 2 t*j 2 N=9 S= Y=25 2 Y = hello B 2 C 3 A 4 C 5 D 6 C 7 A 1 CommonDialog1.ShowColor 2 Flags 3 1 TabStrip 2 ProgressBar 3 Slider A 2 B 3 C 4 B 5 D

313 B 6 B 7 C 8 A 9 D 10 D 11 C 12 D 1 1 Call C 2 B 3 B 4 A 5 A 6 C 7 D 8 C A 2 C 3 D 4 D vbtest2(a,b) 3 1 Optional 2 IsMissing 3 4 Variant 4 ParamArray

314 Visual Basic B 2 A 3 D 4 D 5 C 6 A 7 D 1 TextBox DragMode 2 Drag 3 DragDrop 4 DragOver 4 MousePointer A 2 D 3 D 4 B 1 1 Unload 2 Show 2 Caption 3 1 Show 2 Unload 4 1 Unload Me 2 Show 5 Initialize C 2 A 3 C 302

315 B 1 1 Form1.frm 2 Module1.bas 3 1.vbp 2.exe D 2 B 3 D 4 A 5 C 1 1 Dim Public 3. ( ) 3 Sub Main 4 DoEvents B 2 D 3 D 4 B B 2 A 3 B 4 D 5 B 6 D 7 A 303

316 Visual Basic 1 1 Lock 2 Unlock 2 1 True 2 Unlock ~ D 2 D 3 C 4 B 5 D 6 B 7 A 8 A 9 A 10 D 1 Open "newfile1.dat" For Output As #1 2 Open "newfile2.dat" For Input As # Open 2 Print# 3 LineInput# 4 Close 5 1 Input 2 Output 3 Not EOF 6 1 UCase(Text1)="END" 2 Print #1,Text1 7 1 Input 2 #2 3 Line Input #1, str1 4 #1, #2 5 Kill C 2 C 3 A 4 B 5 B 6 C 7 D 8 B 9 C 1 1 Put #1, 1, work1 2 Random 3 1 Type End Type 4 1 Put 2 Get 2 Get #1, 1, work

317 B B 2 A 3 A Drive1_Change 2 Dir1_Change 4 1 *.* 2 Pattern_Change D 2 D 3 D 4 B 5 D 1 kill "c:\vbtest\ *.txt" 2 FileCopy " d:\vbtest\source.doc", " target.doc" 3 Name "c:\vbtest\oldfile.txt" As "c:\vbtest\ex\oldfile.txt" 4 Name "c:\vbtest" As "c:\vbtestnew" 5 Shell "c:\vbtest\ run.exe ",1 305

318 C 1 Visual Basic A 2 D 3 D 4 B 5 D 6 C 7 B 8 A 9 D 10 B 11 A 12 C 13 B ADO 5 F vbp 2.vbg Shift+F7 2 Ctrl+R 3 Ctrl+G 2 Visual Basic 2.5

319 C 1 C 2 B 3 D 4 B 5 C 6 C 7 A 8 D 9 C 10 C 11 B 12 A 13 A 14 D 15 B 16 B 17 B 18 B 19 C 20 C 21 C 22 A 23 B Text1 3 Timer Sa&ve 3 Visual Basic A 2 A 3 B 4 D 5 A 6 B 7 B 8 B 9 B 10 D 11 B 12 D 13 C 14 B 15 B 16 B 17 D 18 A 19 C 20 B 21 A 22 D GoTo Lp 2 i 3 m 3 1 Ltrim() 2 Rtrim() 3 Trim() 4 1 Debug 2 Print 5 1 Ucase() 2 Lcase() 6 1 End 2 Stop 7 1 F5 2 Ctrl+Break 3 Shift+F5 8 1 Asc(x$) 2 Str$(x) 3 Val(x$) 307

320 Visual Basic B 2 A 3 A 4 B 5 B 6 D n Mod i n/i=n\i Int(n/i)=n/I 2 flag =0 5 (1) 1 To m (2)Mid The Length Visual Is Val 2 Val 13 CommonDialog1. Action=3 3 MsgBox C 2 A 3 B 4 C 5 C 6 C 7 A 8 B 9 B 10 B 11 A 308

321 C Fun = p 2 Fun(t) 4 a(5)=25 b(5)= Exit Sub B 2 A 3 D 4 C 5 B 6 D 7 D 1 1 MainForm 2 StartForm vbp Command1 2 Command2 5 Initialize 6 Me 7 1 Unload 2 Show Show 2 Hide Public 3 4 Dim Private 309

322 Visual Basic A 2 A 3 A 4 C 5 A 6 A 7 B 8 C 9 D 10 B 11 D 12 A 13 B 1 Name "c:\vbtest\oldfile.txt" As "c:\vbtest\ex\newfile.txt" 2 1 FileName 2 Pattern 3 1 Dir1.Path=Drive1.Drive 2 File1.Path=Dir1.Path FileCopy " d:\vbtest\old.doc", "new.doc" 5 Shell 6 Kill 7 1 Seek 2 Seek 8 1 FileLen 2 LOF Type End Type 10 1 Open 2 Print# Write# 3 Put 4 Input# LineInput# 5 Get 6 Close 11 1 Change 2 Drive1 3 Drive1_Change() 310

323 D Visual Basic ( 2 70 ) A B C D 1 A B C D 2 A Name B Name C Name D Name 3 EXE A B C D 4 Dim TestDate As Date TestDate A TestDate=#1/1/2002# B TestDate=#"1/1/2002"#

324 Visual Basic C TestDate=date("1/1/2002") 5 D TestDate=Format("m/d/yy","1/1/2002") Dim X As Intenger Sgn(X) 1 X A B 0 C 0 D 0 6 Command1 Static X As Integer Static Y As Integer Cls Y=1 Y=Y+5 X=5+X Print X,Y Command1 A B 15 6 C D a=3 b=5 A a>=b And b>10 B (a>b)or(b>0) C (a<0)eqv(b>0) D ( 3+5>a)And(b>0) 8 x=inputbox(" " "0" " ") 10 A X 10 B InputBox C 0 D X 10 9 str1 str2 A Left B Mid C String D Instr 10 a="visual Basic" b="basic" 312

325 D A b=left(a,8,12) B b=mid(a,8,5) C b=right(a,8,12) D b=left(a,8,5) 11 Change A B C D 12 TextTime Timer1 Private Sub Timer1_ () TxtTime.text=Time A Enabled B Visible C Interval D Timer 13 Option1 Option2 Check1 Text1 Text A Option1.Value=True B Option1.Value=True Check1.value=False Check1.value=True C Option1.Value=False D Option1.Value=True Check1.value=True Check1.value=1 14 Esc Click True A Value B Default C Cancel D Enabled 15 Command1 313

326 Visual Basic For I=1 To 4 For J=0 To I Print Chr$(65+I) Next J Print Next I A BB B A C B D AA CCC BB CC BBB DDDD CCC DDD CCCC EEEEE DDDD EEEE DDDDD 16 A Autosize B Stretch C AutoRedraw D Appearance 17 Text1 Text2 Command1 Dim x As integer, n As Integer x=1 n=0 Do While x<20 x=x*3 n=n+1 Loop Text1.Text=Str(x) Text2.Text=Str(n) A 15 1 B 27 3 C D Text1 Command1 314 Dim I As Integer, n As Integer

327 D For I= 0 To 50 I=I+3 n=n+1 if I>10 Then Exit For Next Text1.Text=Str(n) A 2 B 3 C 4 D 5 19 Text1 Command1 Dim array1(10,10) As Integer Dim I, j As Integer For I=1 To 3 For j=2 To 4 array(i,j)=i+j Next j Next I Text1.Text=array1(2,3)+array1(3,4) A 12 B 13 C 14 D Command1 Dim I As integer, j As integer Dim a(10,10) As integer For I=1 To3 For j=1 To 3 a(i,j)=(i-1)*3+j print a(i,j) Next j print Next I 315

328 Visual Basic A 123 B 234 C 147 D Option Base 0 Private Sub Form1_Click() Dim a Dim I As Integer a=array(1,2,3,4,5,6,7,8,9) For I=1 To3 print a(5-i); Next A B C D A Form_Load B C Sub D 0 23 Command1 F1 F1 F1 1 0 A x=inputbox("") a=f1(val(x)) print a Function F1(ByteRef b As Integer) If b Mod 2 =0 Then Return 0 Else 316

329 D Return 1 End If End Function B x=inputbox("") a=f1(val(x)) print a Function F1(ByteRef b As Integer) If b Mod 2 =0 Then F1= 0 Else F1=1 End If End Function C x=inputbox("") a=f1(val(x)) print a Function F1(ByteRef b As Integer) If b Mod 2 =0 Then F1=1 Else F1= 0 End If End Function D x=inputbox("") a=f1(val(x)) print a Function F1(ByteRef b As Integer) If b Mod 2 =0 Then Return 1 Else Return 0 End If End Function 317

330 Visual Basic 24 Text1 Command1 Dim x,y,z As Integer x=5 y=7 z=0 Text1.Text="" Call P1(x,y,z) Text1.Text=Str(z) Sub P1(ByVal a As Integer, ByVal b As Integer,c As Integer) c=a+b A 0 B 12 C Str(z) D 25 A Static Static B Sub Sub C Sub Sub D 26 A KeyUp KeyDown A a KeyCode B KeyUp KeyDown 11 KeyCode C Keypress D Keypress 27 A B & C Visiable D 28 menu1 A menu1.enabled=true B menu1.enabled=false 318

331 D C menu1.visible=true D menu1.visible=false 29 A B ShowOpen ShowSave C ShowOpen D ShowColor 30.txt A "text(.txt) (*.txt)" B " (.txt) (.txt)" C "text(.txt) (*.txt)" D "text(.txt)(*.txt)" 31 A Sub Main B Show C Hide Unload D 32 A B Private C VB D 33 Type Books Name As String *10 TelNum As String *20 End Type A Dim B As Books Open "c:\person.txt" For Output As #1 B.Name = InputBox(" ") B.TelNum=InputBox(" ") 319

332 Visual Basic Write #1, B.Name, B.TelNum Close #1 B Dim B As Books Open "c:\person.txt" For Output As #1 B.Name = InputBox(" ") B.TelNum=InputBox(" ") Print #1, B.Name, B.TelNum Close #1 C Dim B As Books Open "c:\person.txt" For Output As #1 B.Name = InputBox(" ") B.TelNum=InputBox(" ") Write #1, B Close #1 D Dim B As Books Open "c:\person.txt" For Output As #1 B.Name = InputBox(" ") B.TelNum=InputBox(" ") Write #1, Name, TelNum Close #1 34 A B C Open D Input# 35 Path A B C 320

333 D D ( 2 30 ) Lable1 Lable2 Caption HScroll Min 0 Max 100 Lable2 1 2 Private Sub HScroll1 1 () Lable2.Caption=Hscroll Command1 Text1 Text2 4 Lable1 Lable2 Lable3 Lable Option1 + * / Text1 Text2 Lable For i=0 To 3 321

334 Visual Basic If 3 =True Then opt=option1(i).caption End If Next Select Case 4 Case "+" Result=Val(Text1.Text)+Val(Text2.text) Case "-" Result=Val(Text1.Text)-Val(Text2.text) Case "*" Result=Val(Text1.Text)*Val(Text2.text) Case "/" Result=Val(Text1.Text)/Val(Text2.text) End Select 5 =Result 3 Command1 Command1 Command1 6 Private Sub Form1_Load() Command.Enabled=False Private Sub Text1_ 6 () Command.Enabled=True 4 pmenu Form1. 7 pmenu Private Sub Form1_Click() Dim x As Single,amax As Single,amin As Single x=inputbox("enter a score") amax=x amin=x 322

335 D Do While 8 If x>amax Then amax=x End If If 9 Then amin=x End If x=inputbox("enter a score") Loop Print "Max=";amax,"Min=";amin 6 Private Sub Form1_Click() Text1.Text=" " Private Sub Text1_Change() Picture1.Print" " Command1 Function M(x As Integer,y As Integer) As Integer M=IIF(x>y,x,y) End Function Dim a As Integer,b As Integer a=100 b=200 Print M(a,b) Lable1 List1 Lable

336 Visual Basic Private Sub Form_Load() List1.AddItem " " List1.AddItem " " List1.AddItem " " Private Sub 14 () Label1.Caption=

337 D Visual Basic C 2 A 3 C 4 A 5 D 6 B 7 B 8 D 9 D 10 B 11 D 12 D 13 D 14 C 15 A 16 B 17 B 18 B 19 A 20 D 21 C 22 C 23 B 24 B 25 D 26 D 27 A 28 D 29 C 30 A 31 C 32 B 33 A 34 B 35 A 1 1 Change _Change 2 Value 2 3 Option1(i).Value 4 opt 5 Lable4.Caption Form1. Lable4.Caption Me. Lable4.Caption Command1.Parent. Lable4.Caption 3 6 Change _Change 4 7 PopupMenu 5 8 x>=0 9 x<amin x<=amin amin>x amin>=x Interval 9 14 List1_DblClick Form1. List1_DblClick Me. List1_DblClick 15 List1 List1.Text Form1. List1 Form1.List1.Text Me. List1 Me.List1.Text 325

338 Visual Basic Visual Basic (1~ ~ ) A B C D 1 A.bas B.res C.frm D.ocx 2 A UnloadForm1 Form1 B Load C Enable False D Height Width 3 Visual Basic A A#A B 4A C?XY D consta 4 Type Student number As String name As String age As String End Type A Student.name=" " B Dim s As Student s.name=" " C Dim s As Type Student s.name=" " D Dim s As Type 326

339 D s.name=" " 5 String(n,"str") A B n C n D n cos ( a + b ) + 5e Visual Basic A Cos(a+b)^2+5*exp(2) B Cos^2 (a+b) +5*exp(2) C Cos(a+b)^2+5*ln(2) D Cos^2 (a+b) +5*ln(2) 7 Command1 a$="software and hardware" b$=right(a$,8) C$=Mid(a$,1,8) MsgBox a$,,b$,c$,1 A software and hardware B software C hardware D 1 8 a=inputbox("today","tomorrow","yesterday",,,"",5) A Today B Tomorrow C Yesterday D Day Before Yesterday 9 A Max B LargeCharge C Value D Max-Min 10 List1 Lable1 A Private Sub List1_Click() Lable1.Caption=List1.ListIndex 327

340 Visual Basic B Private Sub List1_Click() Lable1.Name=List1.ListIndex C Private Sub List1_Click() Lable1.Name=List1.Text D Private Sub List1_Click() Lable1.Caption=List1.Text 11 Command1, Private Sub Command_Click() x=0 n=inputbox("") For i=1 To n For j =1 To i x=x+1 Next j Next i Print x, 3 A 3 B 4 C 5 D 6 12 A B Enabled False C D 13 chkoption. A Tag B Index C ListIndex D Name 14 Command1 328

341 D Option Base 0 Private Sub Command_Click() Dim city AsVariant city=array(" "," "," "," ") Print city(1),, A B C D 15 Function Fun(S As String)As String Dim s1 As String For i=1to Len(S) s1= UCase(Mid(S,i,1))+s1 Next I Fun =s1 End Function Private Sub Commandl_Click() Dim Strl As String,Str2As String Str1=InputBox(" ") Str2=Fun(Str1) Print Str2 "abcdefg" " " A abcdefg B ABCDEFG C gfedcba D GFEDCBA 16 Open "c:/" For Output As #1 A C Test.Dat B C Test.Dat C 1 329

342 Visual Basic D, Print # Test.Dat 17 A Shell Windows B Shell, Visual Basic C Shell =Shell( ) D Shell DOS 18 A B " " C D 19 TxtA Private Sub TxtA_KeyPress(keyascii as Integer) KeyPress A B C D 20 Path A B C D 21 Private Sub Form_MouseDown(Button As Integer,Shift As Integer,X As Single, Y As Single) If Button=2 Then PopupMenu popform End If A B popform C X Y 330

343 D D Button=2 22 n! A n=5 x=1 Do x=x*i i=i+1 Loop While i<n Print x B n=5 x=1 i=1 Do x=x*i i=i+1 Loop While i<n Print x C n=5 x=1 i=1 Do x=x*i i=i+1 Loop While i<=n Print x D n=5 x=1 i=1 Do x=x*i i=i+1 Loop While I>n Print x 23 Command1 Lable1 Lable2 331

344 Visual Basic Private X As Integer X=5 Y=3 Call proc(x,y) Label1.Caption=X Label2.Caption=Y Private sub Proc(ByVal a As Integer,ByVal b AS Integer) X=a *a Y=b +b, A 5 3 B 25 3 C 25 6 D Command1 Lable1 s=0 For i= 1 To 15 x=2*i 1 If x Mod 3 = 0 Then s=s+1 Next i Lable1.Caption=s, A 1 B 5 C 27 D Command1 3 Label1 Label2 Label3 Private x As Integer Static y As Integer Dim z As Integer n=10 z=n+z y=y+z 332

345 D x=x+z Label1.Caption=x Label2.Caption=y Label3.Caption=z 3 3 A B C D Command1 Static b As Variant b=array(1,3,5,7,9) b 5 9,7,5,3,1 A For i=0 To 5-1\2 Tmp=b(i) b(i)=b(5-i-1) b(5-i-1)=tmp Next B For i=0 To 5 Tmp=b(i) b(i)=b(5-i-1) b(5-i-1)=tmp Next C For i=0 To 5\2 Tmp=b(i) b(i)=b(5-i-1) b(5-i-1)=tmp Next D For i=1 To 5\2 Tmp=b(i) b(i)=b(5-i-1) 333

346 Visual Basic b(5-i-1)=tmp Next 27 Drive1 Dir1 File1 Label1 Label2 Label1 334 A Private Sub Dir1_Change() File1.Path=Dir1.Path Private Sub Drive1_Change() Dir1.Path=Drive1.Drive Label1.Caption=File1.ListCount B Private Sub Dir1_Change() File1.Path=Dir1.Path Private Sub Drive1_Change() Dir1.Path=Drive1.Drive Label1.Caption=File1.List C Private Sub Dir1_Change() File1.Path=Dir1.Path Label1.Caption=File1.ListCount

347 D Private Sub Drive1_Change() Dir1.Path=Drive1.Drive D Private Sub Dir1_Change() File1.Path=Dir1.Path Label1.Caption=File1.List Private Sub Drive1_Change() Dir1.Path=Drive1.Drive Label1.Caption=File1.List 28 Form1 Form2 mdlfunc Form1 Form2 mdlfunc Form1 Private Sub frmfunction1() Form2 Public Sub frmfunction2() mdlfunc Public Sub mdlfunction() A 3 B frmfunction2 mdlfunction C 3 D mdlfunction 29 Text1 Text2 Command1 335

348 Visual Basic Type Person name As String*8 major As String*20 End Type Test29.dat person p A Open "c: Test29.dat" For Random As #1 Put #1,1,p Close #1 B Open "c: Test29.dat" For Random As #1 Get #1,1,p Close #1 C Open "c: Test29.dat" For Random As #1 Len=Len(p) Put #1,1,p Close #1 D Open "c: Test29.dat" For Random As #1 Len=Len(p) Get #1,1,p Close #1 30 CommonDialog1 Command1 Save SaveFile *.txt A 336

349 D CommandDialog1.FileName="SaveFile" CommandDialog1.Filter="All Files *.* (*.txt) *.txt (*.doc) *.doc" CommandDialog1.FilterIndex=2 CommandDialog1.DialogTitle="Save" CommandDialog1.Action=2 B CommandDialog1.FileName="SaveFile" CommandDialog1.Filter="All Files *.* (*.txt) *.txt (*.doc) *.doc" CommandDialog1.FilterIndex=1 CommandDialog1.DialogTitle="Save" CommandDialog1.Action=2 C CommandDialog1.FileName="Save" CommandDialog1.Filter="All Files *.* (*.txt) *.txt (*.doc) *.doc" CommandDialog1.FilterIndex=2 CommandDialog1.DialogTitle="SaveFile" CommandDialog1.Action=2 D CommandDialog1.FileName="SaveFile" CommandDialog1.Filter="All Files *.* (*.txt) *.txt (*.doc) *.doc" CommandDialog1.FilterIndex=1 CommandDialog1.DialogTitle="Save" CommandDialog1.Action=1 ( 2 30 ) 1 ~ 15 1 Visual Basic 1 2 Visual Basic 2 3 S 3 S =5 For i=2.6 To 4.9 Step

350 Visual Basic S =S +1 Next i 4 d:\pic a.jpg Picture z ~300 5 For i=1to 20 x=int( 6 * ) If 7 =0 Then Print x S =S + 8 End If Next i Print "Sum=";S 7 Private Sub Form_Click() Dim a As Integer, b As Integer a=20: b=50 p1 a,b p2 a,b p3 a,b print "a=";a,"b=";b Sub p1(x As Integer,ByVal y As Integer) x=x+10 y =y +20 Sub p2(byval x As Integer,yAs Integer) x=x+l0 y =y +20 Sub p3(byval xas Integer, ByVal y As Integer) x=x+l0 338

351 D y=y+20,, a= 9 b= 10 8 Command1 Dim a As String a= 11 For i=1 To 5 Print Space(6-i);Mid$(a,6-I,2*i-1) Next i,, Combo1 Label1 Label2 Caption ASCII 13 Label2 Label Private Sub Combo1 12 (KeyAscii As Integer) If KeyAscii = 13 Then For i=0 To Combo1.Listcount 1 If Combo1.Text= 13 Then 339

352 Visual Basic Label2.Caption=" " Exit Sub End If Next i Label2.caption=" " Combo1. 14 Combo1.Text End If 10 Private Sub search(a() As Variant,ByVal key As Variant,index%) Dim i% For i = Lbound(a) To Ubound(a) If key = a(i) Then index= i Exit Sub End If Next i index = -1 Private Sub Form_Load() Show Dim b() As Variant Dim n As Integer b=array(1,3,5,7,9,11,13,15) Call search(b,11,n) Print n

353 D Visual Basic D 2 A 3 D 4 B 5 B 6 A 7 C 8 C 9 A 10 D 11 D 12 B 13 B 14 D 15 D 16 A 17 B 18 C 19 D 20 A 21 D 22 C 23 B 24 B 25 C 26 C 27 C 28 D 29 C 30 A Picture1.Picture=LoadPicture( d:\pic\a.jpg ) Picture1=LoadPicture( d:\pic\a.jpg ) 5 5 Timer 6 6 Rnd Rnd(n) n 7 x Mod 5 Int(x/5) x/5 x/5 Int(x/5) CInt(x/5) x/5 x/5 CInt(x/5) Round(x/5)-x/5 x/5 Round(x/5) x (x\5)*5 (x\5)*5 x Fix(x/5) x/5 x/5 Fix(x/5) 8 x Keypress 13 Combo1.List(i) 14 AddItem

354 E Visual Basic ( 2 70 ) A B C D 1 Visual Basic A B C D 2 Visual Basic A ReadOnly B Archive C Hidden D System 3 A Write # 8, math,eng B Write # 8, math;eng C Print # 8,math,eng D Print # 8, math;eng 4 Load A Load B Load Form_Load C Load D 5 Visual Basic A KeyDown B KeyUp C KeyPress D KeyAscii

355 E 6 Sub A Static B Private C Public D Defaut 7 Sub A ByVal B ByRef C ParamArray D Optional 8 Visual Basic A MouseDown B MouseMove C MouseUp D MousePointer 9 a Dim a Sub test() a = a + 1: b = b + 1: c = c + 1 Print "Sub"; a; b; c Private Sub Form_Click() a = 2: b = 3: c = 4 Call test Print "main:"; a; b; c A Sub:3 4 5 B Sub:2 3 4 Main:3 4 5 Main:1 2 3 C Sub:4 1 1 D Sub:3 1 1 Main:4 3 4 Main: VB A Sub B Function C Property D Private 11 k = 1 For j = 1 To 10 k = k j 343

356 Visual Basic Next j MsgBox k \ j A 6 B 5 C 4 D 3 12 CommonDialog A ShowOpen B ShowClose C ShowColor D ShowPrinter 13 For i = 1 To 2 x = 1 For j = 1 To 3 x = 2 For k = 1 To 4 x = x + 6 Next k Next j Next i Print x A 2 B 14 C 26 D x = 0 Do Until x = -1 a = InputBox(" A ") a = Val(a) x = InputBox(" X ") x = Val(x) a = a * x Loop Print a

357 E A 120 C x x + B 15 D 120 y + sin 2x Visual Basic y A SQR(x+y)/(x y)+sin(x*2) B SQR(x+y)/(x y)+sin(2x) C SQR((x+y)/(x y))+sin(x*2) D SQR((x+y)/(x y))+sin(2x) 16 a = 1234 b$ = Str(a) c = Len(b$) Print c A 4 B 5 C 6 D 7 17 a = 1.25 b = 345 c = Len(Str$(a) + Str$(b)) Text1.Text = c A 3 B 4 C 8 D 9 18 a% = 2 / 3 b% = 32 / 9 Print a%; b% 345

358 Visual Basic A 1 4 B 0 3 C 1 3 D a$ = "AAAAAA" a$ = Mid$(a$, 2, 4) Print a$ Mid$(a$, 2, 2) = "aa" Print a$ A AaaA B AAAA C aaaa D aaaa AAAA AaaA aaaa AAAA 20 A Type B Enum C Public D Dim 21 Dim c As Long c = 2222 c& = 8888 Print c; c& A B C D Dim Index% A Dim Index As Long B Dim Index As Integer C Dim Index As Single D Dim Index As Double 23 Type Address Street As String ZipCode As String Phone As String End Type 346

359 E Dim MyHome As Address With MyHome Street = " " ZipCode = "100081" Phone = " " End With Print MyHome.Phone A B C D Type Person no As Integer name As String * 13 brith As Date salary As Single End Type Dim zhao As Person A B C D 25 a = 0 : m = 5 For i = 1 To m b = 0 For j = 1 To i a = a + 1 b = b + 2 Next j Next i Print a; b A B C D

360 Visual Basic 26 Dim a(4, 4), b(4, 4) For i = 1 To 4 For j = 1 To 4 a(i, j) = i + j b(i, j) = a(i, j) + i + j Next j Next i For i = 1 To 4 For j = 1 To 4 Print Tab(4 * j); a(i, j) + b(i, j); Next j Print Next i A B C D a = Text1.Text If a Mod 2 = 0 Then MsgBox " " Else MsgBox " " End If 23 A 348

361 E B C D 28 Function fact(n) s = 0 For k = 1 To n s = s + (k + 1) * k Next k fact = s End Function A N B N N C N+1 N D N 29 Dim i, MyNum Do For i = 1 To 1000 MyNum = Int(Rnd * 1000) Select Case MyNum Case 7: Exit For Case 29: Exit Do Case 54: Exit Sub End Select Next i Loop A 7 B DO C D

362 Visual Basic x = InputBox(x) If x Mod 3 = 0 Then y = x Mod 3 If x Mod 3 = 1 Then y = x Mod 3 If x Mod 3 = 2 Then y = x Mod 3 Print y 68 A 0 B 1 C 2 D 31 Sub ABC() Dim Number, MyString Number = InputBox(n) If Number = 1 Then GoTo L1 Else GoTo L2 L1: MyString = "Number = 1" Print MyString GoTo L3 L2: MyString = "Number < > 1" Print MyString L3: Print MyString Call ABC InputBox 35 A Number 1 B Number <> 1 Number 1 Number <> 1 C Number 1 D Number <> 1 Number <> 1 Number 1 32 For j = 8 To 35 Step 3 350

363 E Print j; Next j A 10 B 9 C 27 D For i = 1 To 6 a = a + i Next i Print a A 10 C B 15 D 28 s = 0 i = 1 While i <= 100 s = s + 1 Wend Print s A 125 B 512 C D Visual Basic A B C D ( 2 30 )

364 Visual Basic 1 1 k = 1 For j = 1 To 5 k = k * j Next j MsgBox k / j 2 2 BB$ = "Visual Basic 6.0" m = Len(BB$) For j = 1 To m B$ = Mid$(BB$, j, 1) If B$ = "a" Then X = X + 1 Next j MsgBox X 3 Sub vbtest2(byval x As Integer,ByVal y As Integer) Print " x=";x;" y=";y x=x+y Print " x=";x;" y=";y Sub Form_Click() Dim a As Integer, b As Integer a=5:b=6 Print " a=";a;" b=";b Call 3 Print " a=";a;" b=";b vbtest Name Form1 Form2 352

365 E Form1 Form1 Command1 Form1 Form2 Private Sub Command1 Click() 6 Me Form Dim A(11 to 30) 10 8 s = 1 For m = 1 To 3 If m <= 1 Then a = 1 ElseIf m <= 2 Then a = 2 ElseIf m <= 3 Then a = 3 Else a = 4 End If 'Print a Sum = Sum + a Next m Print Sum; 11 9 & Save v a$ = "Good morning!" b$ = "Even" c$ = Left$(a$, 5) + LCase$(b$) + Right$(a$, 4) 353

366 Visual Basic Print c$ books no 40 name 20 score 10 brithdate Type books no As String*40 name As String*20 score1 14 brithdate 15 End Type 354

367 E Visual Basic 1 D 2 A 3 B 4 C 5 A 6 B 7 C 8 C 9 D 10 D 11 B 12 B 13 C 14 B 15 C 16 B 17 D 18 A 19 B 20 B 21 D 22 B 23 C 24 A 25 C 26 B 27 A 28 C 29 D 30 C 31 B 32 A 33 C 34 C 35 B vbtest2(a,b) Type End Type 5 6 Unload 7 Show Sa&ve Good evening! As Single 15 As Date 355

368 Visual Basic Visual Basic ( 2 70 ) A B C D 1 Visual Basic A B C D 2 Visual Basic A List B Multiselect C Pattern D FileName 3 Type Student no As Integer name As String * 10 score(1 To 4) As Integer End Type Dim stu1 As Student A B C D 4 A B C Visual Basic D 356

369 E 5 Visual Basic A MouseDown B MouseMove C MouseUp D MousePointer 6 3 Text1.Text = UCase(Text1.Text) Private Sub Command2_Click() Text1.Text = LCase(Text1.Text) Private Sub Command3_Click() Text1.Text = Text1.Tag Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer) Text1.Tag = Text1.Text Abc Command1 Command2 Command3 A ABC abc ABC B ABC abc Abc C abc ABC Abc D abc ABC abc 7 Sub test(x%, y%, z%) z% = x% + y% a% = 12.5: b% = 40.2 Call test(a%, b%, c%) Print c% A 0 B 52 C 53 D 8 Sub Sub test(x As Single, y As Single) 357

370 Visual Basic t = x x = t + 2 y = t - 2 Dim a As Single Dim b As Single a = 10 b = 4 Call test(a, b) Print a, b A 12 8 B 10 4 C 8 6 D X = 0 Do Until X = -1 A = InputBox(" A ") A = Val(A) B = InputBox(" B ") B = Val(B) X = InputBox(" X ") X = Val(X) A = A + B + X Loop Print A A 2 B 3 C 14 D

371 E Sub subp(b() As Integer) For i = 1 To 3 b(i) = b(i) + i Next i Dim a(1 To 3) As Integer a(1) = 10 a(2) = 20 a(3) = 30 Call subp(a) For i = 1 To 3 Print a(i), Next i A B C D Combo1 Command1 a = Combo1.List(1) Print a Private Sub Form_Load() Combo1.AddItem "12" Combo1.AddItem "34" Combo1.AddItem "56" A 12 B 34 C 56 D 0 12 A LostFocus B OutFocus C Lost D Fause 13 ListBox1 359

372 Visual Basic Dim Entry, i, Msg Msg = "Choose OK to add 100 items to your list box." MsgBox Msg For i = 1 To 100 Entry = "Entry" & i List1.AddItem Entry Next i A AddItem 100 B AddItem 1~100 C AddItem 1~100 D AddItem Label1 A Label1.Enabled = False B Label1.Enabled = True C Label1.Visible = True D Label1.Visible = False 15 VB ( ) A Shift+Ctrl B Shift+ C Ctrl+ D Ctrl+ 16 Txt1 A Txt1.MultiLine=True B Txt1.MultiLine=True Txt1.ScrollBars=0 Txt1.ScrollBars=3 C Txt1.MultiLine=False D Txt1.MultiLine=False Txt1.ScrollBars=0 Txt1.ScrollBars=3 17 Value A Move B Change C Scroll D GotFocus 18 Form1 A Load Form1 B Form1.Show C Form1.Hide D Unload Form Command1 Command2 Command3 Command2.Enabled = False Command3.Visible = False 360

373 E A Command1 Command2 Command3 B Command1 Command2 Command3 C Command1 Command2 Command3 D Command1 Command2 Command3 20 Combo1 Chardonnay Fun_Blanc Gewrztraminer Zinfandel Combo1 Private Sub Form_Load() Combo1.AddItem "Chardonnay" Combo1.AddItem "Fun_ Blanc" Combo1.AddItem "Gewrztraminer" Combo1.AddItem "Zinfandel" text1 A Text1.Text = Combo1.List(0) B Text1.Text = Combo1.List(1) C Text1.Text = Combo1.List(2) D Text1.Text = Combo1.List(3) 21 Visual Basic A 128 B 256 C 512 D a.txt A Open " a.txt " For Append As #1 B Open " a.txt " For Output As #1 C Open a.txt For Append As #1 D Open a.txt For Output As #1 23 A Dim B Public C Static D Private 24 a=6 x=iif(a>5, 1,0) x A 5 B 6 C 0 D 1 25 x x = 0 361

374 Visual Basic For i = 1 To 20 Step 2 x = x + i \ 5 Next i Print x A 16 B 17 C 18 D For i = 1 To 4 x = 4 For j = 1 To 3 x = 3 For k = 1 To 2 x = x + 6 Next k Next j Next i Print x A 7 B 15 C 157 D A My Documents B VB98 C \ D Windows 28 S 2 3 A Mid(S, 3, 2) B Mid (S, 2, 3) C MidStr(S, 3, 2) D MidStr(S, 2, 3) 29 A B C D 30 Tan 30 Visual Basic A Tan30 B Tan (30) C Tan (30 ) D Tan (30*3.14/180) 362

375 E 31 A ReDim Preserve A(10,Ubound(A,2)+1) B ReDim Preserve A(Ubound(A,1)+1,10) C ReDim Preserve A(Ubound(A)+1) D ReDim A((UBound)(A)+1) 32 Dim a(10) For j = 0 To 10 a(j) = j - 5 Next j Text1.Text = a(a(6)/a(10)) A 5 B 1.6 C 0 D 33 Dim a(50) For j = 0 To 10 j = j * j a(j) = j Next j Text1.Text = a(25) A 5 B 25 C 45 D Dim a(10) For i = 1 To 10 a(i) = i ^ 2 Next i Print a(i 2) 363

376 Visual Basic A 64 B 81 C 99 D Dim a(4, 4), b(4, 4) For i = 1 To 4 For j = 1 To 4 a(i, j) = i + j b(i, j) = a(i, j) + i + j Next j Next i For i = 1 To 4 For j = 1 To 4 Print Tab(4 * j); a(i, j) + b(i, j); Next j Print Next i A B C D ( 2 30 )

377 E Private Sub Drive1_Change() 3 Private Sub Dir1_Change() 4 3 Visual Basic.vbp Visual Basic 7 ByVal 8 5 N MsgBox n = InputBox(" ") k = Int(Sqr(n)) i = 2 flag = 0 Do While i <= k And flag = 0 If 9 = 0 Then flag = 1 Else i = i + 1 End If Loop If 10 Then MsgBox " ", vbokonly, " " Else MsgBox " ", vbokonly, " " End If 6 InputBox 365

378 Visual Basic n = InputBox(" ") m = Len(n) For j = 11 dec = dec * 2 + Val( 12 (n, j, 1)) Next j Print ""; dec 7 A = B = 12.3 c$ = "+" d$ = Str$(A) + c$ + Str(B) MsgBox d$ 13 8 Visual Basic

379 E Visual Basic 1 B 2 D 3 A 4 D 5 B 6 B 7 B 8 A 9 A 10 A 11 B 12 A 13 A 14 D 15 B 16 B 17 B 18 B 19 C 20 C 21 A 22 A 23 B 24 D 25 A 26 B 27 B 28 B 29 B 30 D 31 B 32 D 33 A 34 B 35 B Dir1.Path=Drive1.Drive 4 File1.Path=Dir1.Path vbp n Mod i n/i=n\i Int(n/i)=n/I 10 flag = To m 12 Mid

380 F 1 National Computer Rank Examination NCRE 2 NCRE 1994 NCRE 3 NCRE NCRE 4 NCRE NCRE Internet

381 F QBasic C Fortran FoxBASE+ Visual Basic Visual FoxPro PC PC PC Windows PC B B B B 5 NCRE Visual Basic Visual FoxPro 90 QBasic C Fortran FoxBASE QBasic C Fortran FoxBASE+ 60 Visual Basic Visual FoxPro 90 B 90 6 NCRE NCRE Fortran Fortran 4 9 B

382 Visual Basic 9 ( ) ( ) ~90 89~80 79~60 59~0 12 Word Excel PowerPoint Office Internet PC Pentium PC PC Windows 98 PC 370

383 F Internet 13 NCRE 1994 NCRE / NCRE NCRE

VB程序设计教程

VB程序设计教程 高 等 学 校 教 材 Visual Basic 程 序 设 计 教 程 魏 东 平 郑 立 垠 梁 玉 环 石 油 大 学 出 版 社 内 容 提 要 本 书 是 按 高 等 学 校 计 算 机 程 序 设 计 课 程 教 学 大 纲 编 写 的 大 学 教 材, 主 要 包 括 VB 基 础 知 识 常 用 程 序 结 构 和 算 法 Windows 用 户 界 面 设 计 基 础 文 件 处

More information

《Visual Basic程序设计》实验课

《Visual Basic程序设计》实验课 Visual Basic Visual Basic [email protected] 0 Visual Basic 1 0...1 1 Visual Basic...2 2...3 3...6 4...9 5...13 6...16 7...18 8...22 9...24 10...27 11...29 12 API...31 13...34 14...35 15...38 1 1 Visual

More information

四川省普通高等学校

四川省普通高等学校 四 川 省 普 通 高 等 学 校 计 算 机 应 用 知 识 和 能 力 等 级 考 试 考 试 大 纲 (2013 年 试 行 版 ) 四 川 省 教 育 厅 计 算 机 等 级 考 试 中 心 2013 年 1 月 目 录 一 级 考 试 大 纲 1 二 级 考 试 大 纲 6 程 序 设 计 公 共 基 础 知 识 6 BASIC 语 言 程 序 设 计 (Visual Basic) 9

More information

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

2010年3月计算机等级考试四级网络工程师笔试 计 算 机 二 级 VB 经 典 预 测 题 下 列 各 题 A) B) C) D) 四 个 选 项 中, 只 有 一 个 选 项 是 正 确 的 请 将 正 确 选 项 填 涂 在 答 题 卡 相 应 位 置 上, 答 在 试 卷 上 不 得 分 (1) 下 列 叙 述 中 正 确 的 是 ( ) A) 循 环 队 列 是 队 列 的 一 种 链 式 存 储 结 构 B) 循 环 队 列 是 队

More information

<4D F736F F D D342DA57CA7DEA447B14D2DA475B57BBB50BADEB27AC3FEB14DA447B8D5C344>

<4D F736F F D D342DA57CA7DEA447B14D2DA475B57BBB50BADEB27AC3FEB14DA447B8D5C344> 1. 請 問 誰 提 出 積 體 電 路 (IC) 上 可 容 納 的 電 晶 體 數 目, 約 每 隔 24 個 月 (1975 年 更 改 為 18 個 月 ) 便 會 增 加 一 倍, 效 能 也 將 提 升 一 倍, 也 揭 示 了 資 訊 科 技 進 步 的 速 度? (A) 英 特 爾 (Intel) 公 司 創 始 人 戈 登. 摩 爾 (Gordon Moore) (B) 微 軟 (Microsoft)

More information

Microsoft PowerPoint - OPVB1基本VB.ppt

Microsoft PowerPoint - OPVB1基本VB.ppt 大 綱 0.VB 能 做 什 麼? CH1 VB 基 本 認 識 1.VB 歷 史 與 版 本 2.VB 環 境 簡 介 3. 即 時 運 算 視 窗 1 0.VB 能 做 什 麼? Visual Basic =>VB=> 程 式 設 計 語 言 => 設 計 程 式 設 計 你 想 要 的 功 能 的 程 式 自 動 化 資 料 庫 計 算 模 擬 遊 戲 網 路 監 控 實 驗 輔 助 自 動

More information

untitled

untitled Visual Basic 2005 (VB.net 2.0) [email protected] 立 六 數 串 數數 數 數 串 數 串 數 Len( 串 ) 串 度 Len( 123 )=3 LCase( 串 ) 串 LCase( AnB123 ) anb123 UCase( 串 ) 串 UCase( AnB123 ) ANB123 串 數 InStr([ ], 串 1, 串 2[,

More information

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

Microsoft Word - 小心翼翼的二十一點N.doc 投 稿 類 別 : 資 訊 類 篇 名 : 小 心 翼 翼 的 二 十 一 點 作 者 : 陳 鈺 文 國 立 瑞 芳 高 級 工 業 職 業 學 校 資 訊 二 李 伯 謙 國 立 瑞 芳 高 級 工 業 職 業 學 校 資 訊 二 胡 家 媛 國 立 瑞 芳 高 級 工 業 職 業 學 校 資 訊 二 指 導 老 師 : 周 曉 玲 老 師 陳 思 亮 主 任 壹 前 言 一 研 究 動 機 平

More information

2

2 1 2 1-1 Visual Basic 3 1-2 3/8-3/21 3/22-4/4 4/5-4/18 4/19-5/2 5/3-5/16 5/17-5/30 5/31-6/13 6/14-6/27 6/28-7/11 7/12-7/25 7/26-8/8 8/9-8/22 8/25-9/5 9/6-9/19 9/20-10/3 10/4-10/17 10/18-10/31 11/15-11/28

More information

FY.DOC

FY.DOC 高 职 高 专 21 世 纪 规 划 教 材 C++ 程 序 设 计 邓 振 杰 主 编 贾 振 华 孟 庆 敏 副 主 编 人 民 邮 电 出 版 社 内 容 提 要 本 书 系 统 地 介 绍 C++ 语 言 的 基 本 概 念 基 本 语 法 和 编 程 方 法, 深 入 浅 出 地 讲 述 C++ 语 言 面 向 对 象 的 重 要 特 征 : 类 和 对 象 抽 象 封 装 继 承 等 主

More information

untitled

untitled 說 參 例 邏 邏 1. 說 2. 數 數 3. 8 4. 理念 李 龍老 立 1. 理 料 2. 理 料 3. 數 料 4. 流 邏 念 5. 良 6. 讀 行 行 7. 行 例 來 邏 1. 說 說 識 量 2. 說 理 類 3. 數 數 念 4. 令 5. 良 6. 流 邏 念 7. 說 邏 理 力 1. 2. 3. 4. 5. 列 念 1 參 1. ( Visual Basic 例 ) (1)

More information

穨ac3-3.PDF

穨ac3-3.PDF 3-1 Access 3-1-1 Event Click OnClick Click OnClick AfterUpdate BeforeUpdate On After Before > VBA( ) 3-1 3-1 Access Open Load Sub Funtion 3-1-2 Sub Funtion Private Me Me Forms Reports Form Report VisualBasic

More information

SMM667.mps

SMM667.mps 第 章 设 计 简 单 程 序 本 章 是 学 习 VB 程 序 设 计 的 入 门 篇, 其 中 涉 及 的 几 个 常 用 控 件 和 基 本 语 句 是 后 续 章 节 中 反 复 使 用 的 基 础 内 容 学 习 目 标 瞯 了 解 顺 序 程 序 结 构 瞯 熟 悉 用 户 界 面 的 设 计 和 简 单 代 码 设 计 瞯 掌 握 赋 值 语 句 和 InputBox MsgBox Print

More information

MVB-1001.DOC

MVB-1001.DOC 20 1.5 10 15 20 25 80 100 CSF 1. 2. 0105 3. 4. 5. 30% 1.5 0.75 1. Visual Basic Visual Basic (A) Visual Basic Enterprise Edition (B) Visual Basic Script Edition (C) Visual Basic Learning Edition (D) Visual

More information

untitled

untitled 1 Outline 數 料 數 數 列 亂數 練 數 數 數 來 數 數 來 數 料 利 料 來 數 A-Z a-z _ () 不 數 0-9 數 不 數 SCHOOL School school 數 讀 school_name schoolname 易 不 C# my name 7_eleven B&Q new C# (1) public protected private params override

More information

基于UML建模的管理管理信息系统项目案例导航——VB篇

基于UML建模的管理管理信息系统项目案例导航——VB篇 PowerBuilder 8.0 PowerBuilder 8.0 12 PowerBuilder 8.0 PowerScript PowerBuilder CIP PowerBuilder 8.0 /. 2004 21 ISBN 7-03-014600-X.P.. -,PowerBuilder 8.0 - -.TP311.56 CIP 2004 117494 / / 16 100717 http://www.sciencep.com

More information

untitled

untitled 21 Visual FoxPro Visual FoxPro 6.0 11 Visual FoxPro Visual FoxPro CIP Visual FoxPro 2004 21 ISBN 7-03-014834-7 V Visual FoxPro TP311.138 CIP 2004 143035 16 100717 http://www.sciencep.com * 2004 12 7871092

More information

VB控件教程大全

VB控件教程大全 Datagrid DataGrid1.Columns.Remove(0) ' 0 DataGrid1.Columns.Add(0).Caption= ' DataGrod1.Columns(0).DataField= Name ' Adodc1.Refresh DataGrid BackColor Font DataGrid CellPadding HTML CellSpacing HTML Width

More information

INTRODUCTION TO COM.DOC

INTRODUCTION TO COM.DOC How About COM & ActiveX Control With Visual C++ 6.0 Author: Curtis CHOU [email protected] This document can be freely release and distribute without modify. ACTIVEX CONTROLS... 3 ACTIVEX... 3 MFC ACTIVEX

More information

Visual Basic D 3D

Visual Basic D 3D Visual Basic 2008 2D 3D 6-1 6-1 - 6-2 - 06 6-2 STEP 1 5-2 (1) STEP 2 5-3 (2) - 6-3 - Visual Basic 2008 2D 3D STEP 3 User1 6-4 (3) STEP 4 User1 6-5 (4) - 6-4 - 06 STEP 5 6-6 (5) 6-3 6-3-1 (LoginForm) PictureBox1

More information

epub 94-3

epub 94-3 3 A u t o C A D L AY E R L I N E T Y P E O S N A P S T Y L E X R E F - AutoLISP Object ARX A u t o C A D D C L A u t o C A D A u t o d e s k P D B D C L P D B D C L D C L 3.1 Wi n d o w s A u t o C A D

More information

Microsoft PowerPoint - Chapter5

Microsoft PowerPoint - Chapter5 CH5 表 單 與 控 制 項 課 程 目 標 : 暸 解 VBA 語 言 中 的 控 制 項 及 常 用 屬 性 表 單 在 視 窗 環 境 中, 使 用 者 所 使 用 的 對 話 窗, 精 靈 等 都 是 以 表 單 為 基 本 單 位, 再 加 上 其 它 控 制 項 所 構 成 的 操 作 環 境 利 用 插 入 表 單 為 指 定 的 專 案 插 入 一 個 自 訂 表 單 表 單 常

More information

ThreeDtunnel.doc

ThreeDtunnel.doc (12) 1 1. Visual Basic Private Sub LoadDatabase() Dim strip As String Dim straccount As String Dim strpassword As String Dim strdatabase As String Dim strtable As String Dim strsql As String Dim strtemp1

More information

6-1 Table Column Data Type Row Record 1. DBMS 2. DBMS MySQL Microsoft Access SQL Server Oracle 3. ODBC SQL 1. Structured Query Language 2. IBM

6-1 Table Column Data Type Row Record 1. DBMS 2. DBMS MySQL Microsoft Access SQL Server Oracle 3. ODBC SQL 1. Structured Query Language 2. IBM CHAPTER 6 SQL SQL SQL 6-1 Table Column Data Type Row Record 1. DBMS 2. DBMS MySQL Microsoft Access SQL Server Oracle 3. ODBC SQL 1. Structured Query Language 2. IBM 3. 1986 10 ANSI SQL ANSI X3. 135-1986

More information

TwinCAT 1. TwinCAT TwinCAT PLC PLC IEC TwinCAT TwinCAT Masc

TwinCAT 1. TwinCAT TwinCAT PLC PLC IEC TwinCAT TwinCAT Masc TwinCAT 2001.12.11 TwinCAT 1. TwinCAT... 3 2.... 4... 4...11 3. TwinCAT PLC... 13... 13 PLC IEC 61131-3... 14 4. TwinCAT... 17... 17 5. TwinCAT... 18... 18 6.... 19 Maschine.pro... 19... 27 7.... 31...

More information

CC213

CC213 : (Ken-Yi Lee), E-mail: [email protected] 49 [P.51] C/C++ [P.52] [P.53] [P.55] (int) [P.57] (float/double) [P.58] printf scanf [P.59] [P.61] ( / ) [P.62] (char) [P.65] : +-*/% [P.67] : = [P.68] : ,

More information

IsPostBack 2

IsPostBack 2 5 IsPostBack 2 TextBox 3 TextBox TextBox 4 TextBox TextBox 1 2 5 TextBox Columns MaxLength ReadOnly Rows Text TextMode TextMode MultiLine TextMode MultiLine True False TextMode MultiLine Password MulitLine

More information

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

2009年3月二级VB语言笔试真题 2008 年 9 月 计 算 机 二 级 VB 语 言 真 题 一 选 择 题 ( 每 题 2 分, 共 计 70 分 ) 1. 一 个 栈 的 初 始 状 态 为 空 现 将 元 素 1 2 3 4 5 A B C D E 依 次 入 栈, 然 后 再 依 次 出 栈, 则 元 素 出 栈 的 顺 序 是 A)12345ABCDE B)EDCBA54321 C)ABCDE12345 D)54321EDCBA

More information

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

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 27 1 Vol.27 No.1 CEMENTED CARBIDE 2010 2 Feb.2010!"!!!!"!!!!"!" doi:10.3969/j.issn.1003-7292.2010.01.011 OPC 1 1 2 1 (1., 412008; 2., 518052), OPC, WinCC VB,,, OPC ; ;VB ;WinCC Application of OPC Technology

More information

untitled

untitled 1 .NET 利 [] [] 來 說 切 切 理 [] [ ] 來 說 拉 類 類 [] [ ] 列 連 Web 行流 來 了 不 不 不 流 立 行 Page 類 Load 理 Response 類 Write 料 Redirect URL Response.Write("!! ives!!"); Response.Redirect("WebForm2.aspx"); (1) (2) Web Form

More information

多層次傳銷與獎金系統

多層次傳銷與獎金系統 醒 吾 技 術 學 院 資 訊 管 理 系 ( 五 專 部 ) 九 十 六 學 年 度 畢 業 專 題 多 層 次 傳 銷 與 獎 金 系 統 組 員 : 921506122 游 濬 瑋 921506126 陳 彥 宇 921506139 林 龍 華 921506144 陳 昶 志 921506149 楊 璧 如 指 導 老 師 : 汪 淵 老 師 中 華 民 國 九 十 七 年 一 月 十 一 醒

More information

数据结构与算法 - Python基础

数据结构与算法 - Python基础 Python 教材及课件 课件及作业见网址 xpzhang.me 1 1. Python 2. 3. (list) (tuple) 4. (dict) (set) 5. 6. 7. 2 Python Python 3 Python 4 Python 1, 100, -8080, 0,... 0x 0-9, a-f 0 xff00, 0 xa432bf 5 1.24, 3.14, -9.80,...

More information

Microsoft Word - 第3章.doc

Microsoft Word - 第3章.doc Java C++ Pascal C# C# if if if for while do while foreach while do while C# 3.1.1 ; 3-1 ischeck Test() While ischeck while static bool ischeck = true; public static void Test() while (ischeck) ; ischeck

More information

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

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 1 Framework.NET Framework Microsoft Windows.NET Framework.NET Framework NOTE.NET 2.0 2.0.NET Framework.NET Framework 2.0 ( 3).NET Framework 2.0.NET Framework ( System ) o o o o o o Boxing UnBoxing() o

More information

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

高 职 计 算 机 类 优 秀 教 材 书 目 * 序 号 书 号 (ISBN) 书 名 作 者 定 价 出 版 / 印 刷 日 期 ** 配 套 资 源 页 码 计 算 机 基 础 课 1 978-7-111-30658-0 计 算 机 应 用 基 础 刘 升 贵 29.00 2012 年 8 月 高 职 计 算 机 类 优 秀 教 材 书 目 * 序 号 书 号 (ISBN) 书 名 作 者 定 价 出 版 / 印 刷 日 期 ** 配 套 资 源 页 码 计 算 机 基 础 课 1 978-7-111-30658-0 计 算 机 应 用 基 础 刘 升 贵 29.00 2012 年 8 月 电 子 教 案 P1 2 978-7-111-27081-2 计 算 机 应 用 基 础 ( 第 2

More information

Microsoft Word - 01.DOC

Microsoft Word - 01.DOC 第 1 章 JavaScript 简 介 JavaScript 是 NetScape 公 司 为 Navigator 浏 览 器 开 发 的, 是 写 在 HTML 文 件 中 的 一 种 脚 本 语 言, 能 实 现 网 页 内 容 的 交 互 显 示 当 用 户 在 客 户 端 显 示 该 网 页 时, 浏 览 器 就 会 执 行 JavaScript 程 序, 用 户 通 过 交 互 式 的

More information

Microsoft Word - 102119003.htm

Microsoft Word - 102119003.htm 102 年 度 11900 電 腦 軟 體 設 計 丙 級 技 術 士 技 能 檢 定 學 科 測 試 試 題 本 試 卷 有 選 擇 題 80 題, 每 題 1.25 分, 皆 為 單 選 選 擇 題, 測 試 時 間 為 100 分 鐘, 請 在 答 案 卡 上 作 答, 答 錯 不 倒 扣 ; 未 作 答 者, 不 予 計 分 准 考 證 號 碼 : 姓 名 : 選 擇 題 : 1. (4)

More information

C/C++ - 函数

C/C++ - 函数 C/C++ Table of contents 1. 2. 3. & 4. 5. 1 2 3 # include # define SIZE 50 int main ( void ) { float list [ SIZE ]; readlist (list, SIZE ); sort (list, SIZE ); average (list, SIZE ); bargragh

More information

概述

概述 OPC Version 1.6 build 0910 KOSRDK Knight OPC Server Rapid Development Toolkits Knight Workgroup, eehoo Technology 2002-9 OPC 1...4 2 API...5 2.1...5 2.2...5 2.2.1 KOS_Init...5 2.2.2 KOS_InitB...5 2.2.3

More information

CHAPTER VC#

CHAPTER VC# 1. 2. 3. 4. CHAPTER 2-1 2-2 2-3 2-4 VC# 2-5 2-6 2-7 2-8 Visual C# 2008 2-1 Visual C# 0~100 (-32768~+32767) 2 4 VC# (Overflow) 2-1 2-2 2-1 2-1.1 2-1 1 10 10!(1 10) 2-3 Visual C# 2008 10! 32767 short( )

More information

C/C++ - 字符输入输出和字符确认

C/C++ - 字符输入输出和字符确认 C/C++ Table of contents 1. 2. getchar() putchar() 3. (Buffer) 4. 5. 6. 7. 8. 1 2 3 1 // pseudo code 2 read a character 3 while there is more input 4 increment character count 5 if a line has been read,

More information

epub83-1

epub83-1 C++Builder 1 C + + B u i l d e r C + + B u i l d e r C + + B u i l d e r C + + B u i l d e r 1.1 1.1.1 1-1 1. 1-1 1 2. 1-1 2 A c c e s s P a r a d o x Visual FoxPro 3. / C / S 2 C + + B u i l d e r / C

More information

( CIP) /. :, ( ) ISBN TP CIP ( 2005) : : : : * : : 174 ( A ) : : ( 023) : ( 023)

( CIP) /. :, ( ) ISBN TP CIP ( 2005) : : : : * : : 174 ( A ) : : ( 023) : ( 023) ( CIP) /. :, 2005. 2 ( ) ISBN 7-5624-3339-9.......... TP311. 1 CIP ( 2005) 011794 : : : : * : : 174 ( A ) :400030 : ( 023) 65102378 65105781 : ( 023) 65103686 65105565 : http: / /www. cqup. com. cn : fxk@cqup.

More information

科学计算的语言-FORTRAN95

科学计算的语言-FORTRAN95 科 学 计 算 的 语 言 -FORTRAN95 目 录 第 一 篇 闲 话 第 1 章 目 的 是 计 算 第 2 章 FORTRAN95 如 何 描 述 计 算 第 3 章 FORTRAN 的 编 译 系 统 第 二 篇 计 算 的 叙 述 第 4 章 FORTRAN95 语 言 的 形 貌 第 5 章 准 备 数 据 第 6 章 构 造 数 据 第 7 章 声 明 数 据 第 8 章 构 造

More information

<4D F736F F D DA5BFA6A1C476C1C92DBEC7ACECB8D5A8F728B57BB35D292E646F63>

<4D F736F F D DA5BFA6A1C476C1C92DBEC7ACECB8D5A8F728B57BB35D292E646F63> 全國高級中等學校 106 學年度商業類科學生技藝競賽 程式設計 職種 學科 試卷 選手證號碼 ( 崗位編號 ): 姓名 : 注意事項 : 請將答案劃記於答案卡, 未依規定劃記者不予計分 試題說明 :( 選擇題共 25 題每題 4 分, 答錯不倒扣, 共 100 分 ) ( )1. 執行以下 Visual Basic 程式片段, 其結果為何?(A) 15 (B) 12 (C) 7 (D) 3 Dim

More information

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

全 国 高 等 职 业 教 育 规 划 教 材 21 世 纪 高 职 高 专 规 划 教 材 系 列 高 等 职 业 教 育 计 算 机 专 业 规 划 教 材 选 题 征 集 通 知 一 选 题 范 围 ( 不 仅 限 于 此 ) 选 题 方 向 选 题 名 计 算 机 基 础 计 算 机 应 用 刘 瑞 新 金 牌 作 者 经 典 作 品 教 授, 计 算 机 专 业 资 深 学 科 带 头 人, 多 部 著 作 获 得 全 国 优 秀 畅 销 书 奖 他 所 编 写 的 教 材 内 容 均 来 自 教 学 实 践, 是 对 编 写 讲 义 教 学 修 改 教 学 讲 义 再 次 教 学 整 个 过 程 的 精 确 提 炼, 因 此 对 促 进 教 师 教 学 学 生 学 习 发 挥 了 重

More information

untitled

untitled Visual Basic 6.0 Visual Basic 6.0 /. 2001.8 ISBN 7-115-10518-9 I. V II. III. BASIC IV. TP312 CIP (2002) 055959 Visual Basic Microsoft 14 1~6 Visual Basic 7~14 Internet Windows API ActiveX Visual Basic

More information

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

全国计算机技术与软件专业技术资格(水平)考试 全 国 计 算 机 技 术 与 软 件 专 业 技 术 资 格 ( 水 平 ) 考 试 2008 年 上 半 年 程 序 员 下 午 试 卷 ( 考 试 时 间 14:00~16:30 共 150 分 钟 ) 试 题 一 ( 共 15 分 ) 阅 读 以 下 说 明 和 流 程 图, 填 补 流 程 图 中 的 空 缺 (1)~(9), 将 解 答 填 入 答 题 纸 的 对 应 栏 内 [ 说 明

More information

WinMDI 28

WinMDI 28 WinMDI WinMDI 2 Region Gate Marker Quadrant Excel FACScan IBM-PC MO WinMDI WinMDI IBM-PC Dr. Joseph Trotter the Scripps Research Institute WinMDI HP PC WinMDI WinMDI PC MS WORD, PowerPoint, Excel, LOTUS

More information

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

Microsoft Word - 專題製作研究報告書.doc 大 富 翁 之 我 要 畢 業 指 導 老 師 : 王 啟 修 參 賽 學 生 : 吳 皇 逸 林 晉 逸 黃 亭 瑋 賴 建 豫 嘉 義 高 商 資 料 處 理 科 摘 要 本 專 題 以 大 富 翁 遊 戲 為 基 本 題 材, 並 參 考 任 天 堂 遊 戲 公 司 製 作 的 Mario Party 電 視 遊 戲 和 各 代 的 大 富 翁, 將 不 同 風 格 的 小 遊 戲 與 傳 統

More information

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

3 Driver do Microsoft Access (*.mdb) hisdata IFIX 1.4 IFix3.5 ACCESS ACCESS hisdata D:\Dynamics\SampleSystem\HistoricalData ODBC DSN hisdata 1 ODBC 1.1 2 1.2 3 Driver do Microsoft Access (*.mdb) 1.3 4 hisdata IFIX 1.4 1.4 5 Access 1.5 6 ODBC ifix3.5 1.6 1.6

More information

untitled

untitled VB 來 立 李 龍老 年 參 車 令 度 綠 車 不 不 靈 了 來 令來 了老 利 來 練 念 邏 念 數 度 念 狀 不 度 令 數 更 參 VB VB VB 理 VB 類 數 (x,y) (0,0) x y x,y 數 (0,0) (x, 0) (0, y) (x, y) VB 裡 來 VB 來 1 Graphics VB Graphics Private Sub Button1_Click(

More information

SYSMAC-SCS Version 2

SYSMAC-SCS Version 2 CX-Programmer- CX-Programmer 2.0 CX-Programmer OMRON OMRON OMRON Unit OMRON PLC i CX-Programmer OMRON, 2000 1, 2, 3 OMRON OMRON OMRON ii CX-Programmer CX-Programmer OMRON SYSMAC CS, CV C PLC PLC CX-Programmer

More information

2 1999 9 21 2001 21 2001 7 20 90 2002 9 2 21 4 38 30 3 ~ 6 3 2004 12 Ⅰ 1!!!!!!!!!!!!!!!!!!! 2 1. 1 2!!!!!!!!!!!!!!! 1. 2 8!!!!!!!!!!!! 1. 3 19!!!!!!!!!!!!!!!!! 2!!!!!!!!!!!!!!!!!!! 26 2. 1 26!!!!!!!!!!!!

More information

优合会计考点直击卷子之财经法规答案——第八套

优合会计考点直击卷子之财经法规答案——第八套 原 题 导 航 基 础 第 一 套 第 1 题 参 考 答 案 : C 试 题 评 析 : 在 社 会 主 义 市 场 经 济 条 件 下, 会 计 的 对 象 是 社 会 再 生 产 过 程 中 主 要 以 货 币 表 现 的 经 济 活 动 第 2 题 参 考 答 案 :B 试 题 评 析 : 在 权 责 发 生 制 下, 本 期 售 货 尚 未 收 到 销 售 货 款 属 于 当 期 收 入

More information

untitled

untitled 1 LinkButton LinkButton 連 Button Text Visible Click HyperLink HyperLink 來 立 連 Text ImageUrl ( ) NavigateUrl 連 Target 連 _blank _parent frameset _search _self 連 _top 例 sample2-a1 易 連 private void Page_Load(object

More information

Excel VBA Excel Visual Basic for Application

Excel VBA  Excel Visual Basic for Application Excel VBA Jun5,00 Sub 分頁 () Dim i As Integer Dim Cname As String Dim Code As Variant Set score=thisworkbook.sheets("sheet") Code=Array(" 專北一 "," 專北二 "," 專北三 "," 專桃園 "," 專桃竹 "," 專中苗 ", " 專台中 "," 專台南 ","

More information

05 CHAPTER Information.IsNumeric ( ) Information.IsDate ( ) True False Date Date True False Y Y Information.IsArray ( ) True False Y Information.IsErr

05 CHAPTER Information.IsNumeric ( ) Information.IsDate ( ) True False Date Date True False Y Y Information.IsArray ( ) True False Y Information.IsErr 05 CHAPTER Information.IsNumeric () Information.IsDate () True False Date DateTrue False Y Y Information.IsArray () True False Y Information.IsError () Information.IsNothing () True False True False Y

More information

coverage2.ppt

coverage2.ppt Satellite Tool Kit STK/Coverage STK 82 0715 010-68745117 1 Coverage Definition Figure of Merit 2 STK Basic Grid Assets Interval Description 3 Grid Global Latitude Bounds Longitude Lines Custom Regions

More information

C/C++程序设计 - 字符串与格式化输入/输出

C/C++程序设计 - 字符串与格式化输入/输出 C/C++ / Table of contents 1. 2. 3. 4. 1 i # include # include // density of human body : 1. 04 e3 kg / m ^3 # define DENSITY 1. 04 e3 int main ( void ) { float weight, volume ; int

More information

C/C++ - 文件IO

C/C++ - 文件IO C/C++ IO Table of contents 1. 2. 3. 4. 1 C ASCII ASCII ASCII 2 10000 00100111 00010000 31H, 30H, 30H, 30H, 30H 1, 0, 0, 0, 0 ASCII 3 4 5 UNIX ANSI C 5 FILE FILE 6 stdio.h typedef struct { int level ;

More information

Ps22Pdf

Ps22Pdf 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

More information

Windows XP

Windows XP Windows XP What is Windows XP Windows is an Operating System An Operating System is the program that controls the hardware of your computer, and gives you an interface that allows you and other programs

More information

提问袁小兵:

提问袁小兵: C++ 面 试 试 题 汇 总 柯 贤 富 管 理 软 件 需 求 分 析 篇 1. STL 类 模 板 标 准 库 中 容 器 和 算 法 这 部 分 一 般 称 为 标 准 模 板 库 2. 为 什 么 定 义 虚 的 析 构 函 数? 避 免 内 存 问 题, 当 你 可 能 通 过 基 类 指 针 删 除 派 生 类 对 象 时 必 须 保 证 基 类 析 构 函 数 为 虚 函 数 3.

More information

User’s Manual

User’s Manual V7 用 户 手 册 亿 图 为 您 专 业 图 表 设 计 提 供 最 佳 解 决 方 案 2004-2014 EdrawSoft. All right reserved. Edraw and Edraw logo are registered trademarks of EdrawSoft. 目 录 亿 图 怎 样 优 越 于 其 他 软 件... 5 亿 图 7 个 新 功 能... 6 为

More information

, 7, Windows,,,, : ,,,, ;,, ( CIP) /,,. : ;, ( 21 ) ISBN : -. TP CIP ( 2005) 1

, 7, Windows,,,, : ,,,, ;,, ( CIP) /,,. : ;, ( 21 ) ISBN : -. TP CIP ( 2005) 1 21 , 7, Windows,,,, : 010-62782989 13501256678 13801310933,,,, ;,, ( CIP) /,,. : ;, 2005. 11 ( 21 ) ISBN 7-81082 - 634-4... - : -. TP316-44 CIP ( 2005) 123583 : : : : 100084 : 010-62776969 : 100044 : 010-51686414

More information

單元5

單元5 13-1 13-2 / 13-3 14-1 Visual Basic 14-2 14-3 15-1 15-2 15-3 287 290 307 13-1 13-1.1 272 Introduction to Computer Science 13-1.1 1. 2. 3. 4. 273 274 Introduction to Computer Science 275 13-1.2 13-1.1 /

More information

1 4 1.1 4 1.2..4 2..4 2.1..4 3.4 3.1 Java.5 3.1.1..5 3.1.2 5 3.1.3 6 4.6 4.1 6 4.2.6 5 7 5.1..8 5.1.1 8 5.1.2..8 5.1.3..8 5.1.4..9 5.2..9 6.10 6.1.10

1 4 1.1 4 1.2..4 2..4 2.1..4 3.4 3.1 Java.5 3.1.1..5 3.1.2 5 3.1.3 6 4.6 4.1 6 4.2.6 5 7 5.1..8 5.1.1 8 5.1.2..8 5.1.3..8 5.1.4..9 5.2..9 6.10 6.1.10 Java V1.0.1 2007 4 10 1 4 1.1 4 1.2..4 2..4 2.1..4 3.4 3.1 Java.5 3.1.1..5 3.1.2 5 3.1.3 6 4.6 4.1 6 4.2.6 5 7 5.1..8 5.1.1 8 5.1.2..8 5.1.3..8 5.1.4..9 5.2..9 6.10 6.1.10 6.2.10 6.3..10 6.4 11 7.12 7.1

More information

2 WF 1 T I P WF WF WF WF WF WF WF WF 2.1 WF WF WF WF WF WF

2 WF 1 T I P WF WF WF WF WF WF WF WF 2.1 WF WF WF WF WF WF Chapter 2 WF 2.1 WF 2.2 2. XAML 2. 2 WF 1 T I P WF WF WF WF WF WF WF WF 2.1 WF WF WF WF WF WF WF WF WF WF EDI API WF Visual Studio Designer 1 2.1 WF Windows Workflow Foundation 2 WF 1 WF Domain-Specific

More information

第三节 软件测试的过程与策略

第三节 软件测试的过程与策略 ...1...4...9...17...25...29...34...40...46...55...65...73 1 2 3 4 5 6 7 8 9 10 11 1 12 13 1 ABCD 2 A B C D 3 ABCD 4 A1/2 B1/3 C1/4 D2/3 5 % A20 B30 C40 D50 6 A B C D 7 A B C D / 8 A B C D 9 A B C D 10

More information

Serial ATA ( Silicon Image SiI3114)...2 (1) SATA... 2 (2) B I O S S A T A... 3 (3) RAID BIOS RAID... 5 (4) S A T A... 8 (5) S A T A... 10

Serial ATA ( Silicon Image SiI3114)...2 (1) SATA... 2 (2) B I O S S A T A... 3 (3) RAID BIOS RAID... 5 (4) S A T A... 8 (5) S A T A... 10 Serial ATA ( Silicon Image SiI3114)...2 (1) SATA... 2 (2) B I O S S A T A... 3 (3) RAID BIOS RAID... 5 (4) S A T A... 8 (5) S A T A... 10 Ác Åé å Serial ATA ( Silicon Image SiI3114) S A T A (1) SATA (2)

More information

Microsoft Word - 97.01.30軟體設計第二部份範例試題_C++_ _1_.doc

Microsoft Word - 97.01.30軟體設計第二部份範例試題_C++_ _1_.doc 電 腦 軟 體 設 計 乙 級 技 術 士 技 能 檢 定 術 科 測 試 範 例 試 題 (C++) 試 題 編 號 :11900-920201-4 審 定 日 期 : 94 年 7 月 1 日 修 訂 日 期 : 96 年 2 月 1 日 97 年 1 月 30 日 ( 第 二 部 份 ) 電 腦 軟 體 設 計 乙 級 技 術 士 技 能 檢 定 術 科 測 試 應 檢 參 考 資 料 壹 試

More information

6. 4 5 6 7 8 9 10 11 ...1... 1...1...1...2... 3...3...5...9... 11...11...11...12...12... 13...13...14... 16...16...19...20 I 1 ---------------------------------------------------3 2 ------------------------------------------------6

More information

ebook43-11

ebook43-11 11 Excel 4 E x c e l Access A c c e s s Access Access / Access 2000 / Paradox S Q L A c c e s s SQL Lotus Org a n i z e r A c c e s s A c c e s s Wo r d Word for Windows O D B C ODBC O ffice A c c e s

More information

广西民族学院(下)

广西民族学院(下) 3888.00 ( 16.00 ) I...1...1...16 ( )...20 ( )...25 ( )...27 ( )...37...49 ()...51 ( )...53 ( )...58...65 ( )...74...80...84...85 ( )...88...91...92 ( )...93... 100... 101... 106... 107 ( )... 115... 118...

More information

C/C++语言 - 运算符、表达式和语句

C/C++语言 - 运算符、表达式和语句 C/C++ Table of contents 1. 2. 3. 4. C C++ 5. 6. 7. 1 i // shoe1.c: # include # define ADJUST 7. 64 # define SCALE 0. 325 int main ( void ) { double shoe, foot ; shoe = 9. 0; foot = SCALE * shoe

More information

Microsoft Word - 13院21号.doc

Microsoft Word - 13院21号.doc 川 教 考 院 2013 21 号 四 川 省 教 育 考 试 院 关 于 全 国 计 算 机 等 级 考 试 体 系 调 整 的 通 知 各 NCRE 考 点 : 为 进 一 步 适 应 新 时 期 计 算 机 应 用 技 术 的 发 展 和 人 才 市 场 需 求 的 变 化, 确 保 全 国 计 算 机 等 级 考 试 ( 以 下 简 称 NCRE) 健 康 持 续 发 展, 教 育 部 考

More information