visual basic 程序设计基础

Click here to load reader

Upload: nansen

Post on 15-Jan-2016

165 views

Category:

Documents


3 download

DESCRIPTION

Visual Basic 程序设计基础. 本课程知识结构. 第 1 章 Visual Basic 6.0 概述 第 2 章 Visual Basic 6.0 语言基础  第 3 章 程序控制结构 第 4 章 构造数据类型 第 5 章 过程  第 6 章 鼠标和键盘事件过程 第 7 章 界面设计 第 8 章 图形与图像设计 第 9 章 文件 第 10 章 数据库程序设计. 小提示. Visual Basic 把程序设计比作兴建工程。因此,启动 Visual Basic 时首先要新建一个工程或打开一个工程文件。. - PowerPoint PPT Presentation

TRANSCRIPT

1
1.
1“”→“”→“Visual Basic 6.0” →“Visual Basic 6.0”Visual Basic 6.0
2“”“EXE”“”
Visual BasicVisual Basic
1 Visual Basic 6.0
VB“”
1 Visual Basic 6.0
4.
1“”→“”“”
2“”Form.frm“”
3“”.vbp
1.1.1 Visual Basic
1.1.2 Visual Basic
1.1.2 Visual Basic
Visual Basic 6.0“”“”Visual Basic 6.0
1 Visual Basic 6.0
1 Visual Basic 6.0
VB
“”“”“”
21180 cm70 kg

Visual Basic 6.0CaptionName

VB
1 Visual Basic 6.0
1 Visual Basic 6.0
Click
DblClick
Load
UnLoad
2.
1CtrlCtrl
2 Visual Basic 6.0

2VBVBabhSVB
a+b*h/2
2“/”Click
2 Visual Basic 6.0
S=(a+b)*h/2
2 Visual Basic 6.0
2 Visual Basic 6.0
"Hello"
2 Visual Basic 6.0
Date8100119999123100000235959#
#January 11997##1 Jan97##5/12/98##1998-5-12 12:30 PM#
2 Visual Basic 6.0
Dim a As Object \`a
Set a=Picture1 \`aPicture1
a.Print "" \`“”
2 Visual Basic 6.0
Empty
Null
Error
Nothing
2 Visual Basic 6.0
“”
1
2 Visual Basic 6.0
2 Visual Basic 6.0
Age As Integer

4
Mod
5
9(^)-*/Mod+-&
2 Visual Basic 6.0
2
“”“”“”“”“”
2 Visual Basic 6.0
5. Eqv
1
3
Visual Basic“+”“&”“+”:
A="Mouse"B"Trap"C=A+BC“MouseTrap”“&”“+”
2 Visual Basic 6.0
2 Visual Basic 6.0

3

4
Print "* ";

3
3.1
3
3.1
3. Date

3
3.1
3
3.1
3
3.1
2End FunctionFunction
4End PropertyProperty LetProperty GetProperty Set
5End SelectSelect Case
6End SubSub
8End WithWith
Exit
2Exit ForFor…NextFor
3Exit FunctionFunction
4Exit PropertyProperty
5Exit SubSub
“”True“1”“2”

IfElseIf
3
3.3.2
End If
“1”True“1”“2”True“2”……“n”
3
3.3.2
=IIf12
“”“1”“”“2”r=IIf(a>512)a>5r=1r=2
3
3.3.3
3
3.3.3
4“”Case“”CaseEnd SelectCase ElseEnd Select
5CaseCase
3
3.4.1 For
3.4

3
3.4.1 For
For“”“”“”“”Next“”“+”“”
3
3.4.1 For
“”01
3
NextFor
3
“”True
While“”True0“”WendWhile“”True“”FalseWend
3
Do…Loop“”
“”Exit Do
1WhileUntilDo…Loop WhileDo…Loop Until
3
3
3.4.4
VB

cj5
3.

(3)3
4
4.1
VB
<>(<>)
4
4.1
Variant
6.

Public|Private|Dim|Static (TO TO …) AS

PublicPrivateDimStatic
“ TO ”“ TO ”
“”“”0



B(i)=InputBox(""&i&"")
arr=Array(1357)
13574arrarr(0)=1arr(1)=3arr(2)=5arr(3)=7Option Base1
4
4.2.3
4
4.3
1.

1
2“”
4
4.3
4“”
2Index
Index
3
4
4.3
3Caption“”
Select Case Index
4
4.4
Enum <>
<1>=<1>
<2>=<2>

2“”
5
5.1.1
1
“”→“”“”“”.frm
5
5.1.1
2
“”→“”“”“”.bas
5
5.1.1
3

“”→“”“”“”.cls
5
5.1.1
“<>=<>”Call“<>(<>)”
4.
5
5.1.2 Sub
1

<1>
“”
“”“”“”“”“”
2


5
5.1.3 Function
<1>
5
5.1.3 Function
2.
Sub“”Function“”“”
5
5.2
5.2.1 Sub
1Call
2
Sub
<><>
5
5.2.2 Function
Dim ss As Double
5
5.3
5.3.1
1.
2.

5
5.3.1
3.

1
2
3
Call ts(50, avrg(), “hello”, a, b)
Sub ts(n As Integera()As Single,b As Rectype,c As String,d As Single)


ByVal
x=x+2
5
5.3.3
1
5
5.3.3
Static s As Long
Dim a As Integerb As Long \`
Private Sub Command1_Click()

Dim
Static
5
5.5.2
6
6.1
6.1.1 MouseDown
Shift

MouseDown:

MouseUp

Shift

MouseMove:

6
6.2
6.2.1 KeyPress


6
6.2.1 KeyPress

6
6.3.1
2DragIcon
DragDrop

6
6.3.1
2DragOver
DragOver

6
6.3.1
left(x)top (y)width height
6
object.Drag action

Private Sub Text1_MouseDown(Button As IntegerShift As IntegerX As SingleY As Single)
Text1.Drag 1
End Sub
7

2
7

2
7.1.1
7
2
3
7.1.1
7
2PopupMenu
7.2
7
“”“”“”“”“”Microsoft Windows Common Controls 6.0“”StatusBar
7.2
7
7.3
7
7.3.1
3

7
7.3.2
2. ImageList
7
7.3.2
7
7.3.2
3“”“”“”“”“1”1
7
7.3.2
4Toolbar

7.4
7
7.4.1
2BorderStyle3Fixed Dialog(MaxButtonMinButtonFalse)


1“”“”“”“”
7
7.4.1
7
7.4.2
2“”5“/”
7
7.4.2
7
7.4.2
7
7.5.2
1“”→“”Form1
2MDI“”“MDI”“MDI”
7
7.5.2
3MDI“”→“”“”“”MDIForm1
7
7.5.2
7.6 VB
7
8.1
8
8.1.1
1. Shape
8
8.1.1
BorderColor
Visible
8
8.1.1
BorderStyle
8
8.1.2
(xy) Step
8
8.1.2
2.
Line

(2)(x1y1)(x2y2)
.CircleStep(xy)

(3)“”111
8.2
8
8.2.1
Picture
“”Picture“”“”
8
8.2.2
8.3
8
8.3.1
Picture1.Cls \` Picture1
DrawWidthLineCircle
FillColorFillStyle
8
8.3.4
CircleClsLinePointPrintPsetAutoRedrawAutoRedrawTrueFormPictureBox
8
8.3.5 Paint
Paint
PaintPaint
2
1
2

9

9
2
9
9.1.1
1
9
9.1.1
2
9
9.1.1
3

ChDrive "D"D
9
9.1.2
3
KillD:DataTest.txtDDataTest.txtKill"C:TEMP*.tmp"CTEMPtmp
9
9.1.2
4
FileCopy "C:MYDIRFILE1""D:MYVBFILE1"
9
9.1.2
5
“”
MkDir<><>
“”“”“”“”
“”
MkDir""
RmDir
9
9.1.2
8
9
9.1.2
2EOF()
9
9.1.2
3LOC()
9.2
9
9.2.1

Open<>For<>Access As#<>Len=

9
9.2.1
4“”4
Shared()
Lock Read
Lock Write
632 767
Close#<>#<>…
“”Open
9
9.2.2
1.Print #
2Spc(n)nTab(n)n
3Print #Print #Print #Print #
9
9.2.2
2.Write#
1Input #
9
9.3.1
9.3

2.
2
10
10.1.1
10.1 SQL
10
10.1.1
AccessFoxPro
10
10.1.1
3Field
10
10.1.1
5Index
6RecordSet
10
10.1.2
SQLSELECTSELECT
SELECT FROM WHEREGROUP BYHAVING ORDER BY ASC|DESC
SELECT
10
10.1.2
(4)GROUP BYGROUP BY
(5)HAVINGHAVING
10
10.1.2

“”
10
10.1.2

“600012”“88”“79”
INSERT INTO VALUES ("600012"“88”“79”)
10
10.2.1
10.2
10
10.2.2
1“”→“”
2“”→“”Microsoft Access 7.0 MDB“”
3“”
10
10.2.2
4“”“”“SQL”“”“SQL”SQL
10
10.2.2
5“”“”“”
10
10.2.2
6“”student
7“”“”“”“”
10
10.2.2
8“”“”“”“”
10
10.2.2
9“”“”“”“”“”“”“”
“”“”
10
10.2.3
1.
1
2“”→“”Microsoft Access“”
3“”“”
4“DBGrid”“”“”“”“”
10
10.2.3
2.
“”“”“”“”
3.
4.
10
3“”

10
10.2.5

1“”→“”Access“.mdb”
2“”→“”
10
10.2.5
3“”“”“”“”4“>”“”“>>”“”“<”“<<”
10
10.2.5
10
10.2.5
5“”→“1”“”“”
10
10.3.1 Data
10.3
DatabaseName
RecordSourceData
10
10.3.1 Data
ReadOnlyTrue
10
10.3.1 Data
2Validate
ValidateRepositionValidate Reposition
10
10.3.1 Data
3Error
10
10.3.2 ADO
ADODataADO“”“”“”Microsoft ADO Data Controls 6.0OLE DB“”ADO
10
10.3.3
1.MSFlexGrid
MSFlexGrid“”→“”“”Microsoft FlexGrid Control 6.0
10
10.3.3
10
10.3.3
10
10.4.1 ADO
10.4 ADO
2.Command
3.Recordset

ConnectionConnection

Recordset
ActiveConnectionConnection
Recordset.Delete AffectRecords
Object.Close