n+1

0

6

N+1

:
$% # &

' ( ) !"# .

.
!,*+ $

http://www.ehsani.org/jooti/

n+1

1

6

!
"
$ ,+%

$% &$ '

#

!% &$
! () % *+
. - *- %&. " /0
+
%$ 2
3 ) %7 ! / %$ 2
3
( 2" 4&
+5
.%7 ! 3 <
- =" (
- (( 9:
! ( 2 " ( ! < $ >&:
9 $ ? <) (
)
( ! %@"
. - ,
( 9: %A B C
*- 7 + ) +D C= &$ )
+ G# $ ="
E F ( 9: E F 5 &G+
=J JH . - * + < F H ! # $ I * + " ! < $ E F
K L
$ @ < $ E F < ) * M N @ ( 9:
<$E F
.="
J@+ O+ ! G-D <
)= N !
! K L = $ ( . ! N ! EH <
! A + C$
) +D C- )
AF
- ( 9: 5 ) & N ! EJ + =G: C, 5 N #
( P- ND Q :
) A
R *+ . =" C, 5
2+ A +
. A- ( 2 " $ $ % & $ )
! %@" % H
A.
.%
$ " &'
!" # $

http://www.ehsani.org/jooti/

n+1

2

C! " S5+ !
=" I !
%. -) 5
%. -) N !
.= +D 5+
! P $ ND
5+

TOJ "
I - .)
9. $ ! %TOJ "
...
U

+ .I

http://www.ehsani.org/jooti/

6

n+1

3

6

&' ( (OOP1)
%! !
! =" %& $ 2+ N &$ V "
.% %
- +5 ) ( 2 " ... $ " I 2L I
>&: ) %& $ 2+ . F .
. A + 7 %@ < *
+$ 2+
=" % $ F
2L <
W%
$ ! =2. N + LO
X
W%
%T L Y+ < .="
) "
W9: W%
$
<
" $ %T L .
( Z [ : I \- E 7 ) % 2L ="
I ="
" < $ %T LI ] " ) %T L
OY+ - %0 +
) G-D & = G... =" " N
< $ %T L ] " ) %A
.
$ $ %T L ] "
) ! # $'
G
- H Y+ ( G"O!) $ "
+
4- ) + " + 4- B>Z %&! W% N 0
.
%+ &0
! =" N - "
. " )
..
-<
.% %
- +... =" N M " ) 9 - ND

6

,-

*.

:

)*+

New Project

! ="
$
$ , + ! < (g M h - Q , - < ( M 5
Q ! D E F BJF
*+
m+ standard exe
7 J
+
t. @+<$
9. 5
N
[M . ) ? + ActiveX Control
! A(g M = T %+ " =" (
(g M
N !) <
- )
(Figure 1-1) $ + N *- =" (
)
!% $
<
! Q , - Standard Exe
9. New - )
!h
<
. !
>! open &!

1

http://www.ehsani.org/jooti/

Object-Oriented Programming

4

n+1

6

Figure 1-1

Figure 1-2

http://www.ehsani.org/jooti/

n+1

5

0

6

12

2:

Hello World
9 I 9 7@: ) .
m2L < %A

A+h
! $)

!(

:2-2

Hello World
"O! Y+
N+ !
! M CommandButton Label, < $

) EA

)

52

)*+

M

!

>! E

:
Private Sub Command1_Click()
Label1.Caption = "hello world"
End Sub
. !
>! Command1 ]&! <

ND < : ) [M

http://www.ehsani.org/jooti/

7

Command1 <

ND

! :

. $

-

„H

) !

+-

n+1

6

(

- ! P

-†

" , + ‡-D

6

*- : + - .
. !ˆ =
'

) < 0 & +%
$ !
2.
X
.
) %A
=" % + N &$ Caption . =" ND Caption I Label % ‰
!
. * + ( N *- Label
.) %H X B m+
7
ND =" :
H
+- ) $ .
7(Properties) ‰
( M
! =A>" Label N &$ „ H .
+- .
H. $
Š N
ND J+
P Caption
- &
!
7+
! :
Command1 &! N )
- + =" (
. $
Š Hello Word
ND
5 < .
#
- ! < ! % @+ +
(event)
G2+
4+
N &$
J
%
- +. ) ?
%@ < ! * + ( 2 " %+ G2+
. *+( 2"
P+I
A + >! &!
< %
<
>!
>! &! <
. F ‹ 2 &!
=" 5
+ Event Handler - < + @Œ
%L < $ !
$<
+@Π5 . !
!
$
!
- ( + - )) •
N ! L $ ! 5 >&: )
$ +
.
7 + + B" (
A+
+ $
Command1 &! < N
>! EH + „ H
. A+
>! &! <
! 1
N
)
+
" 2+ + +%+ Š M E+ 0
" 2
. A+ 7
&! <
>!
) + .
A + =F
E+ 0
" Š M Event Handler 3
. A + L ND
5 < < +. $ + Š Label N 0 + + ) 4
‘ F %+ ‹ 2 &!
<
$< P <$
D " ?
A < ' >
= T
!% $
+- E
$%
click <
7
( M <„
. !
>!

http://www.ehsani.org/jooti/

n+1

7

6

. * + : %7
L • ND ! =" (
: +•
!„H
$ ,+
A < I $
Š Label1 % <
caption = L
[M
! %+ ( 2 " ’.‘ )
$ R7
$
ND = L
%
B
G2+ [M .=" Label1 ) Caption = L % @+ Label1.Caption
: *+5
- !< !
”Hello world“ <
J+
Label1 %
) Caption = L
.(
:
Hello Visual Basic World 5 +
$
Š
Hello World + . $ C &A+
>! E Label1 < %
$
Š
+.
˜ M ND N
:
+! Fš +&!
(TextBox) 5 + 7@:
Label 5 +
: &! < N !
>!
! $
Š < X
!
: . ! Š (
- TextBox
!% +
( ) &! [?"
! Š TextBox 5 + : N +)
.
.
, Label
:5+
Š TextBox 5 + =
$
! $
Š < X E7 + . ! Š 9 - Label 5 + !
:%

) %
T -9 + ŒJ- %+ %
-%
.
%+ ( N *- % ND < $ +
‘=" (Text)5 + < H TextBox ) % L
#
C M ND < <
A + (Change) Š TextBox 5 + %
D
‘ ( +D

>?
! =" Œ# ‘
Quake EY+ % $ <) < M

.2
1.

2.

&$
.0
1.
2.

: ( . ! •" M

1.
Private Sub Command2_Click()
Label1.Caption = Text1.Text
End Sub
2.
Private Sub Text1_Change()
Label1.Caption = Text1.Text
End Sub

<)

.1

@

A

:2-3

=" <) & 'ž 2 $ %&! !Q
<) 5
7T
N+
N+
.=" % : <) %T ! " &-

http://www.ehsani.org/jooti/

n+1

8

:

!

<$ T

+

6

A + Q , - %F
0
+- : +- ¡
.
="
0 ND + - < $ % & $
! ! AF %&!
7
N G&*# „ H
T + ND N ! 9
T +
EH <
5T
.=" A# !
:(
E A* C, " ) + T + Y+ <
%F
0
Q , - 1.
! B"
0N !
2.
! N ! % & $ 3.
$
&$ A# ! < $ C, N ! EH ) [M
.
A+E +

: 1 EH
4! =" ND )
=H %>
!5
. A+
2L 5 %F
0
rnd • . " +
0
Q , - < [M . - P +
0
ž mL C,
: !( 2" ) !) N +(
5

int •

%F

Int(Rnd * 10) + 1

U + F
Label

%>L

T

+

L O@F

7

B 5
- A <
(File\new project\ standard exe)
!)
: (g M
!
.
ND dblclick
)B
$
m2L <

Private Sub Label1_DblClick()

Label1.Caption = Int(Rnd * 10) + 1

End Sub

X,
$ 0
!
>! E
$ $ , &- ! & !< .
[M ‘ ! Q , - %>7
!

ND
-<
#
! : ND
! : (
7
+- . ?
0 N &$ * + : &
+!

)B
0 N ! Q , - ) E7

Randomize Timer

< 0 # ª H %F
0 ! A + 5 @ Randomize "
Q , - ! %F
0 [M .="
" N +) Timer .
Q,< A +- < :
P
="
?+ ! N +) ª H
*+
. * &() * +
,
A" M >&: ) % G- ) KO
: $ Š+« @
+- <
T + 5 . A &- Š + « @
7 +
! %"
%T
Š+« @ <$ "
) % $ % @+
! () N
!ˆ (7
Š + - . ). D %+ C M < ) OA*+ E&0
4: Š+
ND
$ &- &
% Œ
M > ?+ !
$ Š + &$ &
!
P
A < (. P +
.
$ " &$ <„
) "
A+« @
Option Explicit
http://www.ehsani.org/jooti/

n+1

9

6

Private Sub Label1_DblClick()
Randomize Timer

< G*,

&$

9.

Requare

!

: *+( 2"

Dim VarName as VarType

X

" 5
A <
Tools\Option < +
! Fš &
+. ! Q , - Variable Declaration
L Dim " ) Š + N ! « @ <

)
:

(integer)ž

mL h - )

RndNum

Š+« @ <

Dim RndNum as Integer

.=" ( +D +

$
,

Š+h - = T
:
-.
E ( +&$ „ & H ) + - ) ‰ ( m+
Š + $ J+
( m+ 5 @ .
. Š+
( m+I ( m+ ND
! =" N
E
!% $ Š+.
%P
Š + « @ Em+ 9 # $ ) C
$ , . . - *+(
• E
BJF - * + « @ •
ND
(
F<$•
&$
Š+
Declarations =&
(‘
X,
- Option Explicit ! %>m+)
!« @
5 . - ¯ +
( m+ N ! 5 @
9 - private public < >! &>!
( 2 " Declarations C,
BJF dim < : < >! < $ &>!
$ +U
. +&
Š+
( m+ Public . - * +
.(dim - +) A +
m+ F
ND Private
&0
+ A + °2H
%>@F J+ Š +
! %- +)
+
< &0 X
A + « @ Declarations C,
!% $ Š+.
. Š+
F5F 5 )
- *+
I F
%@. F
E
! % $ Š + .( - P +
"
4F H) - * +
) %@ . - •
&0 X
< &0 X - * + « @ •
:( ! ˆ )
! :
) Y+ . - + 5 ) • 5 F 5
Private Sub Command1_Click()
Dim x As Integer
x=x+1
Label1.Caption = x
End Sub
Label1.Caption

B

Private Sub Command1_Click()

&!
. !
>!
. *+(
2L J+ ND ² F C M X
Label
. (x=x+1) * + %>7
J+ ) *
( N *- 1 0 . " , + ! =" N &$
< Š ‘ *+ # 0
!
>! $ P
:

+-

%

.

± H Label

&0 N M x Š + End Sub B
. - P +) E+ 0
"

N "
F .

http://www.ehsani.org/jooti/

K @ ) !
4!
(
: +
&! <
!
*+« @ x Š+
%A
ND J+
- . * + ( C &. + . *+
‘ # ! A &) [M ! E T 5
! < 4F H
" +

n+1

10

P + 2L
:

! :

T
+-

J+
.

*+« @ (
! 5 9P :

static

6

Š+

A+

< >! &>!

dim

>!

...
&>! „ H

Private Sub Command1_Click()
Static x As Integer

. *+ F š „ H A &- < Š ! < 0 !(
(9 @+ . ! :
="
J#
Š+5 + !
P + > ?+ ! static < >! &>!
&0 X dim - + static < $ Š +
!
7
ND ³ + $ , &&- 5 ) Š + • ) ±
ª
5
.="
F
G-D
.=" ( ! °2H
%>7
J+ •
< @ =*.)
: $ Š+h Data type

Storage size

Range

Byte

1 byte

0 to 255

Boolean

2 bytes

True or False

Integer

2 bytes

-32,768 to 32,767

Long
(long integer)

4 bytes

-2,147,483,648 to 2,147,483,647

Single
(single-precision floating-point)

4 bytes

-3.402823E38 to -1.401298E-45 for negative values;
1.401298E-45 to 3.402823E38 for positive values

Double
(double-precision floating-point)

8 bytes

-1.79769313486232E308 to
-4.94065645841247E-324 for negative values;
4.94065645841247E-324 to 1.79769313486232E308 for
positive values

Currency
(scaled integer)

8 bytes

-922,337,203,685,477.5808 to 922,337,203,685,477.5807

Decimal

14 bytes

+/-79,228,162,514,264,337,593,543,950,335 with no
decimal point;
+/-7.9228162514264337593543950335 with 28 places to
the right of the decimal; smallest non-zero number is
+/-0.0000000000000000000000000001

Date

8 bytes

January 1, 100 to December 31, 9999

Object

4 bytes

Any Object reference

String
(variable-length)

10 bytes +
string length

0 to approximately 2 billion

String
(fixed-length)

Length of
string

1 to approximately 65,400

Variant
(with numbers)

16 bytes

Any numeric value up to the range of a Double

Variant
(with characters)

22 bytes +
string length

Same range as for variable-length String

: 2 EH
http://www.ehsani.org/jooti/

n+1

11

6

N
- + - ) %>
4=" 2 ! B C, IC, 5
5 =J JH . 7 &+!
! N # .=" + - C, 5 &G+
) %>
-%
!B
! < +- N
! ! ="
[A0
. $ &- % &$
A+ !Q
A
. A+˜M
. - + P- =" ! %&! +
%
!B
! < +:
+- % 7) 7:
&$ * +
! B ) =7mL % „ &@+
. A+% 7)< F
A+U + F
+!%H
A+
OY+
+! ª" +
+- $´ !
! :
- + %> &
EA <
.
!
windows media
! ! ! ND = - %+ % ! #
player
3 5
0
! 123
$.4
! OY+ ( ! = 0
$
- " ). $ - Š
!
0 .1
(file < +) ˆ# =&" + 5 T )
9. 5 D exit !
0
%¶@ = - 7 0 /0 =" 5A&+
!
: ND &
. ="
.
N !)
%H X G-D <
!B
" *
N
! « X 2.
+N *! ˜ "
O0 < 7+ N
! „ &@+. !
$ ,+< F HN
! ! %T H
- ND K X &$ N
.
& +N
!
) # $
!< 9F undo
5! !
" ) 3.
&> + 5! ˜ M E F NOF :
P + % ) . = - ·&H
! 4.
(!5! ˜ M ND ! =" 5 U 4 +
%2> ,+ < $ J >" $
!.
4 E
! B 5.
4 N
J >" ª H
&
+. *- 7 +
!
4 5 G
² FCM +
!
.
option setting < +
+5T
Q
! B" ¡ X
A < “.( - 7 ( M ) ( "” 6.
! . [M .
!
windows < %
N ! !
% +
7
N„ 5 &$
. ) ? )
X,
&
+- . != J
+4F H .7
.(
( !Q,- % &4
#
!
5 D !
: 3 EH
0) .9 ( !Q,- !< 0 !
P
!
$
%+
. A# ! =" + % , 3
:
A + ( 2 " if %X
" ) < . & <
If Text1.Text > RndNum Then
Label1.Caption = "random# < " + Text1.Text
ElseIf Text1.Text < RndNum Then
2

.
http://www.ehsani.org/jooti/

UI (User Interface)
3

n+1

12

Label1.Caption = "random# > " + Text1.Text
Else
Label1.Caption = "u r winner"
End If
) [M
" .
(ž mL) true

6

if ) @ %JΠ+
-)false .
- *+

70 .
) [M B 5 T
(="
: then
9 - ND R
. .=" ElseIf
!
+R
"
7! =" if
" C, elseif then 5 T ) . * + : else
<
P+˜ >
ND
. - *+ :
R
.
. A + º,*+ ND %P F
* ¡ š
"5 N
- +A" M C
m
. „&H
.
( !
J+ ž mL 0
- P# ! ( +D C M
. A &- < P ," Š + « @ - + 9 +5
h -E 7
=" G + . ! %+ E 7 ž mL 0
text1.text !
h -E 7 !<
+
P+
!( 2" %" h -E 7 )
< +
7 %M !
h - E 7 OA*+
A < .=" žš
5
. * + ) m2L 5 M %A# ! ( M .
view\imidiate window
.
7 B
B
ND

"
- +( M
:

) "
Print 2 + “3”

‘ Œ#

" 5 <

%T .=" 5

0

-

Print “2” + “3”

ž mL

0

A+( 2"
CBool(expression)
CByte(expression)
CDate(expression)
CDbl(expression)
CDec(expression)
CInt(expression)
CCur(expression)
CSng(expression)
CStr(expression)
CVar(expression)
CLng(expression)

N ! •&: <
)<$•

% @ . * + 23
.=" ( ! ‹ mT $
) «> ,+ h E 7 <

boolean h Byte h Date h Double h Decimal h Integer h Currency h Single h String h Variant h Long h -

E 7
E 7
E 7
E 7
E 7
E 7
E 7
E 7
E 7
E 7
E 7

Print Cint(“2”) + “3”

.
. A
!5
) ="
F &H.
E F5

7

!7 4 8 9 ...( ... ..."6
G
( A- %H X <)
F) $ .
! =" N &$
! %H X 5+ ! %+ F

http://www.ehsani.org/jooti/

n+1

13

6

.=" (
( ! %H X 5+ ! % ( " F )
7 ) %>
&
!
U 4+ 0 7!
- + A
( O0
! $ ,+
F<
# ! 7!
5 &$ <
A
!5 $V + I
( ! %H X
textbox 5 + N ! ˜ M < (clr) 5 M ˆ# =&" &!
.
P+N
( G0
ND ! 5
- ! ="
R
! $ +
!% &$
J+ ! $ (cp) &!
5 )
$
- + I< 0 < $ &! + .
- O7
ND < $
:
) 7 < ! $ &!

text1.Text = text1.Text + "1"

5

<
!5
%!5 . $
A-D ) C ( . $ !
ND 5
-< < G (

%T =" Q >Œ+ ( +D ="
- 7T
Š ND
0
BJF
&! (
X , .= + ="
&H
A + paste copy I ! ˆ
< !
!
: !
*
$
" ;
cmdKeyboard
ND J+
! M (Name)
&! ‰
- ‘= # - 5 + .
A &- ² 0
- + m . $
Š
Label1 I Label1.Caption=1 !
.=" P A )
A2
,*+ I
( ! %H X ! < + .=" ND = L Caption %
< G+ &! &$ 5
( A- ² 0
- . . ! ( Pcommand1 ta 12

G
. * + %&. " /0
$ cp &!
! ! " =" G .="
˜ E 5 I $
Š cmdCmpare
<
º ,*
ND h - % H
N
!
< X
<$ - *M )
: ... Label < lbl command < cmd Y+
: =" < 9P+ - < =F " A + (
L
Control type

prefix

Example

Check box

chk

chkReadOnly

Combo box, drop-down list box

cbo

cboEnglish

Command button

cmd

cmdExit

Common dialog

dlg

dlgFileOpen

Directory list box

dir

dirSource

Drive list box

drv

drvTarget

File list box

fil

filSource

Form

frm

frmEntry

Frame

fra

fraLanguage

Image

img

imgIcon

http://www.ehsani.org/jooti/

n+1

14

=H -

6

ImageList

ils

ilsAllIcons

Label

lbl

lblHelpMessage

List box

lst

lstPolicyCodes

Menu

mnu

mnuFileOpen

Option button

opt

optGender

Picture box

pic

picVGA

ProgressBar

prg

prgLoadFile

RichTextBox

rtf

rtfReport

StatusBar

sta

staDateTime

Text box

txt

txtLastName

Timer

tmr

tmrAlarm

N
- %+ G2+ N
X , < @ < $ @: + <

ND - [?"
ND • + .= N ! paste copy

$

! 5 ) %¶@ - .
m2L 5 ( & BJF . A.4
-< !%
<$
<
. : A! ND
%>7 ! P
!² 0 %
! - +
*+<
P- General C,
. - .

&$ % @ - * +
D $
G-D
%A
! #
- .
!5 < „H.
F
m+[ ! $
G-D
D”
"
$
Š cmdKeyboard
$
&! (Name) . $ =7Y+ Q : “‘ ! =" $
!)
D
$ ,+

.* Object Naming Conventions) MSDN

"# $%& "

http://www.ehsani.org/jooti/

' ( # MSDN

!4

n+1

15

6

&! [ . !
h
2L &!
5+ - + $ &
.
. + = - G+
-+. !ª

G-D

( P$
!5
(index)[ - = L „ H
)
G
7T .
I
&!
2L I
! $[ A+
.
ND caption
)[ - T +
. ... 3 2 1
$caption
$[ ) =" < P 9 # & < $caption
.
Š $ [ - N + & <$
<
A + ="
D
! #) %
. *+ L

Private Sub cmdKeyboard_Click(Index As Integer)
End Sub

( F ‹2
[ - ( -

!

!<
&G2 A-D <
NO0
[ - Š+.
.( F ‹ 2 ND <
: $ &!

%$

[M
: ="
! =" %T !
& < < !

Private Sub cmdKeyboard_Click(Index As Integer)
Text1.Text = Text1.Text + cmdKeyboard(Index).Caption
End Sub

%+ !

Œ- &$

D<$

!‰

< " U

ControlName(ControlIndex).Property
%F index=1 • 5

A+
>! 2 &! < % .="
.=" 2
ND caption ! * +
.
0 OY+
. 0 ) Z <9 #
$ &! caption &
G .
textbox
% >P0 $ ,+
- %" F
( 2" )B )

2. ! Œ-D
$ [ - ="
:
!
Text1.Text = Text1.Text + CStr(Index)

!Q,0
BJF <) h
<
!
(
Q , - %F
0 + - < : ¾m+
A <
F ! %- +)
5 .
+ form_load
0Q,R +
< $ %$
J+ < ª" + %>m+
*+ : *+
4F H
.=" T
Private Sub Form_Load()
Form1.Caption = "Find Number"
Text1.Text = ""
Randomize Timer
RndNum = Int(Rnd * 10) + 1
End Sub

0 =F
( +D
%T textbox
J+
$) @ A <
N
>! R + • N
J+ ) [M - + .
< @
• 5
- =" %F ! ! 5 < . ! %F clr &!
: =" )
5+ clr
!
>! • .
Private Sub Command11_Click()
Text1.Text = ""
http://www.ehsani.org/jooti/

n+1

16

6

End Sub
cp •

[M


End If
Command11_Click
End Sub

. $
Š
) C" $ +ž:
$ +
- 7!
< !
! !%
J+ ! enter >! N )
! =" G . A- > 7 ! <
. N ! ˜ M ! Esc N )
$
&!
! true ND . ! - default = L
$ &!
<
>!
-9
enter >!
! % . *A + %A*+
H
true < &! <
. cancel = L
. * + %F &! 5
%F &! ND <
>!
%+ ( ) Esc >! %
BJF F $ . * +
- + cancel &!
BJF default &!
‘ #I
‘ A + cancel
! default
! ! $ &!
- + & „H
K H

ND . =" (

- Label1

70 I Label

. ! ! <)
ND N +
BJF .
EA*+
ND
±
<) )
! <)
$ P ="
<) : 0Q,- <
!
!< !. !
-+
9 # &$ !
: ).
7(.=" (
: () + #
! $ hOX
!N
( R
.=" (
( ) N A+ 5 I ! ˆ 0435 - + < 0 V +
;)

!

<

:

!

M

( -

) A

0 - + $) $ *+( .
P
) N A+ 5 . $
!< D
! A <

:

!<
. !
+ <)
$ ,
: (
+< :
!
5
+ ŠM
N )V H
- +
!
.
P
< %$
:
!%

1.
2.

3.
4.
5.

.1

J+
!˜M( !
% &! 2.
. !
%T textbox * +
J+ E&0 %
!
! < ! 3.
J+ ) @
5T
! ! %- +) ² 0
*.
%T textbox A +
. !5 @
%F
0 ( m+ ! $
!
N A+ 5 4.
.
( N *- ª" + Š M ( m+ ) ±
<$V H<
http://www.ehsani.org/jooti/

n+1

17

6

#
+!
0 ) Z <9 # textbox
! . 5.
< 0 < *0 < $ 0). ! EH EA*+ 5
* + error
(.
>Œ+ - 9 - - * + h
2L
!
:% &$
<9 # - &- & ! " - " * &- ! %L
N
Š ) .0
.
7
ND
$
Š
%+ # $ . ! Q
5
$
! & .1
)5 T < J+ ! - enable - % L
P + (boolean
‘ *+ #
!
J 10
< 0 . 2.

5 . -9 < " textbox ‰
SelLength Selstart
.1-3
%
- ! N +) G
%&- ( N *- Properties Window
V "
(run time : N +)
P ! =" 5
" )
.
$
(
J+ I < 0 >! N ) ) E7
. 3-2.
.
P
&
!˜M 5+ A (
- +
‘ JF + ( * + « @ Declaration
! N &$) < " " Š +
.4
T + %F
0Q,- B
Š %&! textbox
. ! EH
! A- < ! 5 ‡&$ !
! C$
! ) - + .1-5
< G- A+ ND
J+
0
!
- N ! E 7 ) E7 5-2.
( !
! ‡-D !
7
: Œ
&H !< P
help
IsNumeric•
< ")
="
0 @
P
! $
Œ
!
7- 0 . (. -9
="
! š O+ ! U 5 )! A- %
: 5 ‡&$
:
( ! 9 $ M ND ) =" G
N !
Š*+
! % [M . !
0) Z - ! .3-5
- < !
( $ + (keypress) *F
$ &! ) ="
0
.

run time

: ( . ! •" M
1.
Else
Label1.Caption = "u r winner"
Text1.Enabled = False
Dim i As Integer
For i = 0 To 9
cmdKeyboard(i).Enabled = False
Next
cmdCmpar.Enabled = False
End If

. 02 false ! true +,http://www.ehsani.org/jooti/

* .,/

01

5

n+1

18

<)

! %- +)
(enabled=true)

( ! 7@ <)
$
! enable

+h
!5

6

&

<

%$
&
A + ) ZD (

.

2.
Text1.Text = CDbl(Text1.Text) \ 10
( -&
<
/ ) < *0

J <
\ ) ž mL
J <
J
. A + ( 2 " mod )

3-1.
Private Sub cmdCmpar_Click()

End If
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
End Sub
Private Sub cmdKeyboard_Click(Index As Integer)
Text1.SelText = cmdKeyboard(Index).Caption
End Sub
3-2.
Dim cmpred As Boolean
Private Sub cmdCmpar_Click()

End If
cmpred = True
End Sub
Private Sub cmdKeyboard_Click(Index As Integer)
If cmpred Then Text1.Text = "": cmpred = False

End Sub
4.
Int(Rnd * (CDbl(txtEnd.Text) - CDbl(txtbegin.Text))) + CDbl(txtbegin.Text)
.
0 E+
BJF $ textbox 5 !
5-1.
Private Sub Form_Load()

Label1.Caption = “LM NOPQ RST UVW LX YZZ[\”
End Sub
5-2.
Private Sub cmdCmpar_Click()
If Not IsNumeric(Text1.Text) Then Label1.Caption = "just integer": Exit Sub
End Sub
+ "
&$ + A + EH
+ runtime error EA*+ ! 5

2L

!<

0

< *0

0 -

+

5-3.
Private Sub Text1_KeyPress(KeyAscii As Integer)

http://www.ehsani.org/jooti/

!N #
. !

:

! %&- ( D
*+h

7T

n+1

19

6

If Not (Chr(KeyAscii) >= 0 And Chr(KeyAscii) <= 9 Or KeyAscii = 8) _
Then KeyAscii = 0
End Sub

! - % =*$ < ! <
7 ! < $ ! ! & : ž š %&!
!E 7 ! !
! 5 N + chr() "
.
$ %A"
x<
. ! C +)D immidiate ( M
print chr(x)
G
).
• ) ±
) @ (text)5 + N
Š N # (. $
0
$
%A" ! + ! < ! ! $
Š
%A" ! + . =" keypress
2L 5
!< ! ! $<
. * + ( C &(
ND
2L
%A" ! '
7- ([ ?"
>!) 8 ND %A" ! 9
(Ã M ! !)
-< ! !Â$ !. *+
:
! Q , - º,*+ ()
< 0 &
!
< +M
0N )V H
#
&
+- . ! M
0 ND
?+ !
‘ A+

* B C

: 3-3

.

! %+ (
.%A F
=" %A F .
5 Q :.
&
&!
IE F V
%+ &0 +

2"
- " <$ 9
& 7 J +- 5
.
N C &- <
+: +- ¡
N C &- +
J+ .= - )„ < * ¡
< F H % ,
J >" %P
9 # &$
D 5 F . < textbox
< +- +
"
N C &- < Image
. ACDSee - + < G*+
! ‰O $
-5
) N
!( " Q ! 5
N +)
<$ 9
N ! <)
N ! AF
%0" #
X,
.="
¯ +N ) * &$ N ! «*! . ) ?
MSDN(help-e VB)).
P &<9 # =" ) Q ! %
!
(. A- U + F
:)
70
! ( 2 " 5+ ! % $ 9
% h %
%
!

Image
DriveListBox
DirListBox
FileListBox
ListBox

imgPreview
drvImage
dirImage
filImage
lstHistory

ComboBox

cboFilter

OptionButton
CheckBox
TextBox

optPreview(2)
chkPreview
txtAddress

C &: +<$
= T C &: +<$< !
C &< !
: + < G> F C &.(
) O7 ! % G> F = T 5
P• " %" " <
<$ - M
$E FN !
m+ <

C &- U C 9.
( N *- [A0
E F E+ ! V D C &-

http://www.ehsani.org/jooti/

n+1

20

Frame

& V
:

%A

$OptionButton ( -

fraPreview

%
!(
. ! E+ !
+$

. + .

6

Å
( ! %H X N
! < + - O@F
( ! %H X N
! < + - N &$
m2L < N
J >"
$ 9 5
. !

A + $ ´ ! &$ FileListBox DirListBox DriveListBox
.
-E + $
!
*+ : + $
Š

Private Sub dirImage_Change()
filImage.Path = dirImage.Path
End Sub
Private Sub drvImage_Change()
dirImage.Path = drvImage.Drive
End Sub

E F

&

- + &
dirImage ! %
ª

- *+E

+ $
" $B
5
5 .
7
?+ ! < $
. - *+ :
! Š drvImage
C &- ND < $ E F
FileListBox ! %>m+ V D : FileListBox.Path
. $
ND < $
)
DirListBox ! <
V D : DirListBox.Path
. $ N *. $ + N *- DriveListBox ! <
V D : DriveListBox.Drive

http://www.ehsani.org/jooti/

n+1

21

(

6

N *- FileListBox
dll exe < G> F A
.$
.

! % G> F ( ! 5 @ : FileListBox.Pattern
< . =" “*.*” ² F C M J+ . * +
.
Š “*.exe;*.dll”
ND
$ N *) = T
C &- <
P- < < 9 ListBox
‘ ! ± ListBox N + - P#
ND
) !
$
F < < >! C +)D <

Private Sub Command1_Click()
lstHistory.AddItem "1st"
lstHistory.AddItem "2nd"
End Sub

-


P$ +
A- Q , - .
. A+±

7T . - * + ±
± < D ) E7

=
#

T

D

ª

D
$
:
D !
!5 @
) Y+ . * + ± G -

Private Sub Command1_Click()
lstHistory.AddItem "1st"
lstHistory.AddItem "2nd", 0
End Sub

:=

T)

DN !K H<

lstHistory.RemoveItem 1

:(

Q,-

D[ - 5F .<

lstHistory.ListIndex

:=

T

& N !K H<

lstHistory.Clear

:

D

J+ 5 F . <

Var = lstHistory.List(0)

.
«> ,+ (Style)EA

!K H

‘(

Q,D
&! ND [?"

" ! .=" TextBox

J+ 5 F . <
! 5 & %&!

ListBox ) %7 !

ComboBox

0.Dropdown Combo 1.Simple Combo 2.Dropdown List
$ )
$ %+
I ( - ) ListBox TextBox
%T
m+ <
! .=" %- BJF TextBox ( ) ListBox %+ "
.=" ‰
<
+ Q , - ·H N !
Dropdown List ) +

+ ! G-D )
5+ A

Z %> F =+ F %

BJF .=" =

T

!

$ , &- N #
A+( 2"
. !Q,( !5 @
*+ < )
H combo
!
.=" text= L
combo

Private Sub Form_Load()
cboFilter.AddItem "*.bmp;*.jpg;*.gif"
cboFilter.AddItem "*.bmp"
cboFilter.AddItem "*.jpg"
cboFilter.AddItem "*.gif"
cboFilter.Text = cboFilter.List(0)

http://www.ehsani.org/jooti/

n+1

22

6

End Sub
Private Sub cboFilter_Click()
filImage.Pattern = cboFilter.Text
End Sub

%-

F

.

FN
( N *- ) E7 ! %@ ) form_load
.=" ² F C M Œ
DN !Q,- 4& (
Q,D
! * + : %- +) combo
>!
P+
FileListBox.pattern
ND 5 +
Q,D !
. !
m+ G-D
E F<$
9. N + )

9. (

DB
*+
%
M

BJF )

Q , - < < 9 : OptionButton
:
:
) A- .= ¯ % $
. !( 2" <
D
L
$ OptionButton )
! %@" .1
. !Q,$
9. ) %A
! ) E7 N
* &$ 2.
false .
(
Q , - % @+
true . : OptionButton.Value
value
N + $ N ! Q , - < .=" ( *- Q , - % @+
. true J+
Private Sub Form_Load()

optPreview(0).Value = True
End Sub

) N
! F š frame
P optionbutton
: ( P* +)D
E
< $ Optionbutton . !
>! G-D <
! :
+ - frame
.=" 5
G-D ) %A BJF 4mT
$ .
) frame
(! !
-( -+ : <
$ C +)D 5 ) # $
) # $)
value . ! .
!)
/ > < $ Q : 5 F . < < 9 : CheckBox
.=" %2 + Q :
0 .
=" =7Y+ Q : I
1 ND
Private Sub Form_Load()

chkPreview.Value = 1
End Sub
Private Sub filImage_Click()
If chkPreview.Value = 1 And optPreview(0).Value Then
Dim pth As String
pth = filImage.Path
If Right(pth, 1) <> "\" Then pth = pth + "\"
imgPreview.Picture = LoadPicture(pth + filImage.FileName)
End If
End Sub

.
"

>! ND < $
D ) %A <
! * + : %- +) FilImage_click
>! <
$ optPreview
(
checkbox .
" 5 loadpicture " ‘ - P# + . $ + N *- image

http://www.ehsani.org/jooti/

n+1

23

" %+ 4 . -

P+

ND

P+

6

%A F . E F
) N

V D
%+ !

imgPreview.Picture = LoadPicture(filImage.Path + filImage.FileName)
V D ! %- +) Path ! ="
EA*+ + . ! ( 2 "
< !
V D . =" ”d:\“ ”c:\“
L
L
%+ ! Œ- &$ .=" ”d:\program files“ ”c:\windows“
E F $< !
V D ) %A .
-< P
”\“ %A
‹ mT
+ ! = - %> F 5
”c:\windowstest.bmp“ 7

. " ,+
! ! 5 = - ”\“ =" =&" ! ! .
4+5 <
. ! Fš
=" =&" ! ! n
P+n 0
right
"
(.
7 help
$ mid left " ). - P +
$ dblClick <
(R
E
" ) ! 5 &$ - +
! -D )
$
- %+ ! 5 <
+)
„ H 5 &$ )
. ! %F ND Declaration
< " " < $ Š + - + 9 - + - ) • « @ Em+
.=" ( $ ! &$ <„ )
Private Sub Preview()
Dim pth As String
pth = filImage.Path
If Right(pth, 1) <> "\" Then pth = pth + "\"
imgPreview.Picture = LoadPicture(pth + filImage.FileName)
End Sub
Private Sub filImage_Click()
If chkPreview.Value = 1 And optPreview(0).Value Then Preview
End Sub

R

(

C &- [A0
>! E
$ ,+
! !%TH<
+ optionbutton ! * + ( N *>! E
[A0 % L
:.
(
Q , - (1) ND

Private Sub filImage_DblClick()
If chkPreview.Value = 1 And optPreview(1).Value Then Preview
End Sub
image C &- ) [M !
*+ : +
image <
stretch
±
+- ) .
(.
form_load
ND R
Private Sub Form_Load()

imgPreview.Stretch = True
End Sub
.[A0 () - image - * + image () Private Sub Preview()
Dim pth As String

http://www.ehsani.org/jooti/

! :
+- 5 .
*+³9
() + ! ). ! true

[A0 I = L

5

n+1

24

6

pth = filImage.Path
If Right(pth, 1) <> "\" Then pth = pth + "\"
pth = pth + filImage.FileName
txtAddress.Text = pth
lstHistory.AddItem pth
imgPreview.Picture = LoadPicture(pth)
End Sub

$ , + % *.
J+
( ! %F ! %@ ) ! %- +) : A% *.
J+ ! %- +)
! ( 2 " 9 - M ) ND %F
. !( 2" $9- M)
7- 9 %&- < Š +
Private Sub lstHistory_Click()
imgPreview.Picture = LoadPicture(lstHistory.List(lstHistory.ListIndex))
End Sub

(

.

=

T

D %&-

"B 5 ) .
. - ,

:
%$
J+
G-D - - %7" + T %$
J+ $ 9 ) %¶@
. ! T
(
(
() ! % A0 ) ª
$ [A0 !
!< !
%&
[A0
‘=" %7
# N„ . - P
lstHistory
.
9 - ico wmf < $ E F N
!
!< !
. ! @F Z frame $ optPreview( ,- # preview %
. $
lstHistory ) K H N A+
!
textbox
ND V D $ + N *- lstHistory ) [A0 %
. $ N *- ND .
%&- ( N *. $ - C &- [A0 9 - lstHistory ( ,- # preview %
http://www.ehsani.org/jooti/

.1
2.
3.
4.
5.
6.
7.

n+1

25

6

:
. ( N *- 9 - %&
" %2,+ < $ E F !
! < ! .1
enter &! N ) ) [M !
dropdown combo
< ! 2.
.
F š ND = T combo 5 +

$ ,+
! ‡-D N ) V H = > 2 ( . !
3.
(( ! ˆ O7 ‡-D
:
) $
:% &$
5
! : B
B
+- + F8 &! N ) .0
! [A+ 4mT # ‰
$ Š+< V +
. =T H
. P+ &
L
Š + ND J+
(system) %&
" (hidden) %2,+ 1.
... * + ( (press) *F (13)enter %
2.
<$ ! ! .
$
- ND <
:
=J JH
3.
% $ ! !
! ND
5+
5+ = T
D
( ! Fš !
%+ change
! . . ! select
%+ Š
5+
$N
!
X,
. $
: ( . ! •" M

1.

filPreview.Hidden = true
filPreview.System = true
2.
Private Sub Combo1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then Combo1.AddItem Combo1.Text
End Sub
3.
Private Sub Combo1_Change()
Dim i As Integer, selstrt As Integer
For i = 0 To Combo1.ListCount - 1
If Left(Combo1.List(i), Len(Combo1.Text)) = Combo1.Text Then
Combo1.SelStart = Len(Combo1.Text)
selstrt = Combo1.SelStart
Combo1.Text = Combo1.List(i)
Combo1.SelStart = selstrt
Combo1.SelLength = Len(Combo1.Text) - Combo1.SelStart
End If
Next
End Sub

<

:
<

% .=" • + 5 #
m2L
< %
$ + N *- [A0
!
[A0
5 . . $ + N *- % A0 $ ND
http://www.ehsani.org/jooti/

<) 5 : 4F H <)
>! ! $ • + ) %A
A+
>! • + 5 +

26

n+1

6

%>A N &$
- 7- %A .
%+ K H • +
5 %A
= ¯ Em+ [A0 $ !
X, . ) ! - *+
[A0 „ ˆ# =&"
. )
. % @ D %+ U
.="
[A0 ŒJ- ND <)
D

http://www.ehsani.org/jooti/

n+1

27

D*.

2

6

@

:

)*+
A 2 :1-3

5

.

&

.

D
. %+

%! V + < $
< * < $ ! <)

4-

$ +ž:

+-

5 <

< H E7 E F
«ŒT
$) E F

m2L 5+
! - &.=" frmMain ND - 0-flat
U appearance
%+ ! %+ F
5+ ! =" PictureBox
)„ F 9
!< P %
7 J PictureBox . ! =" 0-flat
F - + 9 - ND appearance
$ ,+ +. .
F

Y! !=" E+ ! F
9 N #
! ( 2 " imagebox ) m :
$ N *- BJF [A0
7"
. ² FCM X
- Stertch = L PictureBox .=" <
autosize . . A &Š U () - $
J+ ND Picture = L
.
%+
Æ) - $
! true
2!
L5
=" ( 2<)
+- 5 : +- ¡
7-) . -9 + ND V +
< P
$ +< F < !
%!
(!=" <
h F % < ! 5 *! :
7 \"
( >! V +)
,+
< !%
$ ,+
+< !
10 . % @ . ! M + <)
-& :
ŒJ- ND
\ " N N *- < .
( N *- m2L
7 \ " 10

! ) imagebox &$ 5 +
A + ( 2 " imagebox ) $ 7
< !N
$
! =" 5 Q :
="
: imagebox
ND [ - I $
F < imgRIP - imagebox
[M . ! %+

http://www.ehsani.org/jooti/

2" < @

n+1

28

A

< ).

! Fš +"
$
!

ND visible
!0
.( *- ( N *- : N +)
- P# +
: N +) ImageBox
D ) ( 2 " ! 5 < =H (

$ ,+ + ! A+
. A+

< ! N &$ J
load imgRIP(1) B
1[ imgRIP - imagebox

!

T ND <

.=" load
Private Sub picCowboy_Click()
Load imgRIP(1)
imgRIP(1).Left = 0
imgRIP(1).Top = 0
imgRIP(1).Visible = True
End Sub
%@ .

left =J JH

6

false

. ="

F ˆ# =&" ) % 5 >L F ImgRIP(1).left
+ OY+ .
ND ! =" %
ˆ# =&" ) %
>L F
ˆ# =&" )
F >L F F left =" screen % E
FI F
.=" m2L
6
) twip A> .= - pixel
² FCM
,+ H
.=" (Â 1/1440
G# B
( ! EJ + (0I0) ŒJ"
B
.
( N *- ND
. ! 6 . pixel ! $%& 5 3 /,3 4
http://www.ehsani.org/jooti/

6

n+1

29

*

6

N !
< . A+
BJF ! 5 &> +
< @ [ &G2 A < . ! T < @ < $ [ : ! :
) ! = - N ! « @ Š + <) #

Private Sub picCowboy_Click()
Load imgRIP(imgRIP.Count)
imgRIP(imgRIP.Count - 1).Left = picCowboy.Left
imgRIP(imgRIP.Count - 1).Top = picCowboy.Top
imgRIP(imgRIP.Count - 1).Visible = True
picCowboy.Move 0, 0
End Sub

[ - ) N #. - P+
. =" [ - 5 D )
B

$ imgRIP
" F (0I0)

! % $ imgRIP
@ ImgRIP.count
* %A count [M
( !h
2L
(...
2L [ - BJF % )
@ N #
( ! ! count-1
B ) +
,+
picCowboy
D
.
F š %A
. !h
-D ) <)

< ! N =! H :
O7 .
!( 2"
%! )
$ , + < ! N =! H <
keydown : )
70
%! P
.
D keypress
:
%! < $ >! ) %A 5 F 5 M ¾m+ keydown . keyup
*+
G-D
$ ) [M keypress . >! ND N +D „ ¾m+ keyup
< J+ keypress keyup keydown ( &0
2 . * + %F
! =" keyascii J+ 5 keypress . - N &. D N 0
! ="
+ .=" ! ! ! =J JH %A" ( & .=" >! %A" ( &
.% G: < $ >! Y+ <
-< ! !
%! < $ >! &$
F %+ ‹ 2 $ >! 5 <
!% $
N !
!<
. ! ( 2 " keyup keydown) N %+ : <
4+ N +)
"
!
BJF 4mT
%! < $
: :
* &$ V ! F
I
focus V ! F ! %T ! I - * +
$
5
textbox
&!
. %T =" picturebox
<$
! P$. $ ‰
V ! F
- %+
. !=
A- 5
* &$
%!
)= ¯
J+ $ >! Y! ! <
I >! ! :KeyCode
>! < vbKeyLeft OY+ I - * + h
vbkey
!
% $ (constant
.ˆ# % G:
.=" shift,alt,ctrl < $ >! = @š ( $ N *- : Shift

http://www.ehsani.org/jooti/

n+1

30

6

!Â$ . .
< * žš
) +5
( *- (
*F
5 shift < =" 2L J+
.=" 4
alt <
2
ctrl < 1
J+
%7 ! < $ =T H <
+ = - %>A*+
>! 3 $ . % @ - * + •&: $
$ J+
%T . * + 7
J+ 5
(
(
*F
‘( +D ! ) $ 0 5
: !=
0 5 (2 < 7+
0) <
%7 ! =" 1 ND <
=" =&"
!
! $
I=" shift <
. =" alt %+ " ctrl %+
AND <
) . ) º ,*
5 N +<
AND ) ( 2 "
(.
P- % :
) ! BJF - &- <9 # <
dec
1
2
3
4
5
6
7

bin
001
010
011
100
101
110
111

Dim msg As String
If (Shift And vbShiftMask) = vbShiftMask Then msg = msg + " shift"
If (Shift And vbCtrlMask) = vbCtrlMask Then msg = msg + " cntrl"
If (Shift And vbAltMask) = vbAltMask Then msg = msg + " alt"

.

$
Š
ND top left ! =" %F ! < ! N =! H < „ H
! F . 4- 100 ND 5+
& E + %P
=! H J+
alt,ctrl,shift >! " $ . % @ . * + Q š shift+1
J+
7T
. * + (‘ +) 800 < ! < $ U M X
P-

Private Sub picCowboy_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyLeft Then picCowboy.Left = picCowboy.Left - 100 * (1 + Shift)
If KeyCode = vbKeyDown Then picCowboy.Top = picCowboy.Top + 100 * (1 + Shift)
If KeyCode = vbKeyRight Then picCowboy.Left = picCowboy.Left + 100 * (1 + Shift)
If KeyCode = vbKeyUp Then picCowboy.Top = picCowboy.Top - 100 * (1 + Shift)

End Sub

V + EA N
Š : "
) <) 5 < 5+ . $
Š
MousePointer = L BJF ! 5 <
%- A D $
! ( 2 " 99-custom - + & . ! ( 2 " 2-cross
*
!).
( N *$ MouseIcon
$
%+ !
(N
( G0
F B m+ < ! N !
m+ :
G#
5
Y!
!
< G- ) U) +D %>7 < $
) - BJF =" ( "
C, 5 =J JH
+ . - EA*+ C,
[A0 =" EA*+ N
) $ @
. .
=
A2 %&!
. ! ( Pm2L
,*+
(
±
m2L =" =&" ) < ! .
$ ,+
. - 7 ‡ =" =&"
! M ª" + R
! = EA ND
If picCowboy.Left + picCowboy.Width > frmMain.Width Then _
picCowboy.Left = frmMain.Width - picCowboy.Width

http://www.ehsani.org/jooti/

n+1

31

6

.

*+N
t . /0 C, 5 (
%m š $ A + AF 5+
R
35
-² 0
$ %&- < * ž š
A + «ŒT [M
5 BJF .
P+N
( G@
(5 M „ Iˆ# =&" < ) P
)
(„
N 0 - L ,+) F < $
HET
!žš
!( 2" N !N !·
< %7 J
J+
borderstyle A
.
m+ F
H &
! 0-none
<)
+h
:
M
! 5 < . =" $ 7 \ " & N ! K H
A+ !< ! G
N + %
BJF !
X , + . A + unload
G-D
- Y" $ F
+5
).
(
=" load
! ! unload
(. ! C +)D unload frmMain
If KeyCode = vbKeyF2 Then
Dim i As Integer
For i = 1 To imgRIP.Count - 1
Unload imgRIP(i)
Next
End If

. - * + m+ $ 7 \ "
-„ 0 %&!
m2L <
.

7- 5
ND < :

$ N *- (
!5 @
( -

!

m+

<

!E

& F2

< $ T >.

>! N )
:
@ .1

.
, &- < !
T >. %
!
! < ! 2.
. -&
,- (
K $ < $ T >.
@ +D 3.
+D 5 ª H
& $ T >. %

,E

:2-3

B N ! " < < +DV +<$
A-D <
. ! E 7 % J- + ND N + !
% ! . =" < ( "
!%
- +! A+< D
A *M „ % $ ª š < F N
- +2. &
BJF
$<# ( G
+ O0
) %> < $ +D
! 2. ="
<
: ! EH
) ! line " : º,*+ ŒJ5 B
N ! " 1.
N M h
ŒJ,+ 5 F . =" ( - + %
%+ %* +)D + * &$ - + . A + "
ND B
! $
m2L <
&!
picturebox
[M .
:
)
Private Sub Command1_Click()
Picture1.Line (0, 0)-(Picture1.Width, Picture1.Height)
End Sub

http://www.ehsani.org/jooti/

+
)
D
+

n+1

32

(.=" F
=" N M ŒJpicture %

6

(

F + ) %&! 5+ 4!) " 5
,+ %+
h
ŒJ,+
9- M
09- M $
.=" y %+
0 x %T
forecolor = L )
- + B \- N
Š <
. !( 2"

Private Sub Command1_Click()
Picture1.ForeColor = RGB(0, 100, 200)
Picture1.Line (0, 0)-(Picture1.Width, Picture1.Height)
End Sub

0

) )

- 7- )
B m+ < P :
< GP2" \- 5
! * + ( 2 " \- 5 @ < long
0 5
N ! ! + .=" 2L
%A*+ 16777215
5 &$ . = - < ( " ! G-D N ?" X , %& =*$
5
0 "• 5
A + ( 2 " RGB7 • ) * + E T
%+ (Red)9+ %T
!
. %+ <
N 0 255
2L
\- 5 N 9 + N
Š .=" (Blue)% D < D (Green)97"
. D =" \- 16777215 N + G-D ª !
$
RGB
255,0,0
0,255,0
0,0,255
255,0,255
255,255,0
255,100,0
255,255,255
0,0,0
192,192,192

\9+
97"
%D
C2
)
% - 2"
%A*+
<
!

=" \- " 5 ª !
N $ ,T \- +N
) - + =" =," 5+ - + $ & <
!5 .
. ! ( 2 " * + M : &$ ! ) (

7

Red Green Blue

http://www.ehsani.org/jooti/

!
M

n+1

33

6

ª Z ª 0 long 0 ND
+ ‘ A + (9 @+ RGB •
D
.= - ! < (9 @+ Â $ !9 90 RGB < ) ND N !
:=" ( +D ) E 7 5
+ F
r + g * 256 + b * 256 ^ 2

.=" N
&-”^“
&!
! :
+ - ‘ ( A- U + F ! \ * B ND
. $ =! H ND <
P ( M
" B % . -9
!
%+ ˜ M
˜M=
$ A
= $(
*- ˜ M B
A <
ND (
" A
! " (
ND
.
?
picture <
AutoRedraw = L
! =" %F ! BJF :
. ! =" true
) - %> T $
* + ˜ M + - ) %*, ! % :
! * + %F % ND < paint
="
+ "
: ! C +)D
)
Private Sub Picture1_Paint()
Picture1.ForeColor = RGB(0, 100, 200)
Picture1.Line (0, 0)-(Picture1.Width, Picture1.Height)
End

:

!5 @ N

+

$ P

U

B \-

Picture1.Line (0, 0)-(Picture1.Width, Picture1.Height), RGB(0, 100, 200)

!) B

http://www.ehsani.org/jooti/

,+ 5 F . 2.

n+1

34

6

&! ) %A ! * + %F%
5 MouseDown
(
*F V + < $
< (=" ND [A0
$ MouseUp)
. A+( 2"
5 )
P
!) B <
ŒJ- A
(
*F ! < &! button V + %>@F Em+ y x < $ Š +
.=" keydown shift - + $ Shift . $ + N *- =" (
F< V + ! *+ : %
5 MouseMove
mousedown - + ND < $ + M
J+ (V + ) F ) ! =! H
.="
AutoRedraw = true
+ - E+ ! ! $ 5
Dim X1 As Integer, Y1 As Integer, X2 As Integer, Y2 As Integer
Dim oldX As Integer, oldY As Integer
Private Sub Form_Load()
X1 = 0: Y1 = 0: oldX = 0: oldY = 0
End Sub
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single,
Y As Single)
X1 = X
Y1 = Y
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single,
Y As Single)
If Button = vbLeftButton Then
X2 = X
Y2 = Y
Picture1.Line (X1, Y1)-(oldX, oldY), Picture1.BackColor
Picture1.Line (X1, Y1)-(X2, Y2), RGB(255, 0, 0)
oldX = X2: oldY = Y2
End If
End Sub

"

(

: B line 5 +
A + ˜ M %>7 B line
7
!˜M
line
" ="

" 5T
G). A+

:

http://www.ehsani.org/jooti/

n+1

35

F š ,B

6

"
D) E Π+ " N A+ + - 5
.1
( !
. ! F š (circle " )(
. $
!
\- 5 @ N A+ 2.
. $
!
& N !˜M=>
3.
:
. ! Fš +N ! load save N A+ .1
! [A0 )
RGB
0 " \- N ! E 7 < %@ 2.
(RGB •
:% &$
.
7
picture1.image,LoadPicture,SavePicture ="
G .1
.=" 256 < 7+ N ! E 7
7 < ! 2.
: ( . ! •" M
line

1.
Private Sub cmdLoad_Click()
Picture1.Picture = LoadPicture("c:\image.bmp")
End Sub
Private Sub cmdSave_Click()
SavePicture Picture1.Image, "c:\image.bmp"
End Sub
2.
SubPrivate Type cRGB
r As Byte
g As Byte
b As Byte
End Type
Private Function RGBDecoder(ByVal c As Long) As cRGB
If c < 0 Then Exit Function
RGBDecoder.r = c Mod 256
c = c \ 256
RGBDecoder.g = c Mod 256
RGBDecoder.b = c \ 256
End Function

http://www.ehsani.org/jooti/

n+1

36

6

Timer G :
%H
$
%&- (

F( )*+

ND

.=" )
< $ 9 5 Q : ) %A
.
! ="
P-) =0 " ˜ m +
: N +) 9 5 !
! : .
- %+ &

&

-

9
+-

+

.
4 3 ) C . ="
m+ )
& • + !
X,
)
• +N F Œ
)
A- ( 2 " N
+&
L
) & ) ( 2 " E! . ! < . >: P < $ + . * &-

K º,*+ N +)
.2 < @
.1
#
. ! ="
! . $

*

+

!
$<
˜ m+
)„ 9 #
. - *+E 7 < @
.
² 0
=
# A N &GF
.
%>A*+ 7- < @
N &GF <
@
[?" . ! G ( D 5 F ( OY+)
D G-D )
$
m2L < (imgPicLoad)imagebox
F<
$ &!
D ) : (imgShow)imagebox
.
&!
)

Dim i As Integer
i=i+1
imgShow.Picture = imgLoadPic(i).Picture

ND D %+ $
) %A BJF + .
7
! :
+# A + . & ( G0
D %+
# A !
$
.
( ! « @ dim
I Š + + A E T
! %&- Š
< % [M =" •
&0
Š + h - 5 &0
X,
.
P + 2L J+
*+« @ (
Š+
! : •
:
A + ž m %&!
+Static i As Integer
imgShow.Picture = imgLoadPic(i).Picture
i=i+1

>!

$

.(
< : EA*+ (
EH %>7
OA*+
&$ % %T
* + ( C &- < @
N !
) I A E T . * + RunTimeError # + - * + ( N *- +
- : %
- 5 # (
* %A + [ - 5 . 9
=" G +
!( 2" R
) EA*+ 5 N ! K X <
! < !)
A- ( 2 " R
) * + EH R
N
%>A*+ .
(N %&- if A &Static i As Integer
imgShow.Picture = imgLoadPic(i).Picture
i = (i + 1) Mod imgLoadPic.Count

http://www.ehsani.org/jooti/

n+1

37

6

=" =&" + M ˆ# =&" + M
J ( -&
mod
"
[M . =" &! >0
J+ )
J ( -&
&> +
- P+
.=" imgLoadPic.Count ) A# ! < 0 * &$ EL H
ND - !
BJF & . ! F š + &
9
interval =L
& ‘ = # ND ! + .=" &
$
.=" - ¯ %> + ª H < 0 !

9$ interval $ &
! < ! ! =" % L 5
7T . * + %F
)D $
"• +
(
&
( !h
%>7 %F
%F
*+ $ +" %&
L5
Z
. F %+
ND
- &!
!< !
! %$
J+ 100
Interval
- %+ ! & < % . ! :
+. ! %?! &
>!
+ ! =" < &!
-+ &
!
X,
. *+
enabled . ! ”&start“ ND caption
! Fš &
P
&!
. ! false & <
Š ”&stop“ ND N 0 * +
>! &! 5 < %
$ ,+
T •š
>! &! <
P
.
@F &
!
. .)
Private Sub Command2_Click()
Command2.Caption = IIf(Command2.Caption = "&Start", "&Stop", "&Start")
Timer1.Enabled = Not Timer1.Enabled
End Sub
. I =" R
+ M . ="
# ! if then else
iif
"

" + M
* + ”stop“

var
true
false

Not
false
true

7.
*+( - .
+ M
”start“ + &! N 0 . % @
*+( - .
. * + ”start“ I
7- ”start“ .
. A + not enabled
enabled
J+ < @ B
* + false
true .
A+
ND P
70
. * + true
false .

. ! =! H $ m2L
.
) N &$
!
( A+
ND
! !
! ! &
.
. -9 \-) ‰

=0 "
.

:
+ - .1
%
- +)

! $
Š < X
F<$
) %A
=,
D
-%
- ! $
F < label
-(
˜MI

2.

-

:
!
% 0 " + - : =0 "
$ \-) N ! U + 5
=>
:% &$
http://www.ehsani.org/jooti/

n+1

38

... TextBox

Format

6

" time "
: •" M

Private Sub Form_Load()
Timer1_Timer
End Sub
Private Sub Timer1_Timer()
Label1.Caption = Format(Time, "hh:mm:ss ampm")
If (CDate(Label1.Caption) >= CDate(Text1.Text)) And (CBool(Check1.Value)) Then
Beep
Beep
End If
End Sub
J+
) Label1
( ! L Timer1.TimerI form_load

.

ND
!
ŒJ-

:%
- + - (g M
! =! H U
< ! % @ . ! ( 2< ! +4mT $ < ! N + <) N
=," < ) . -9
( " F %F

http://www.ehsani.org/jooti/

n+1

39

6

0 1 : L1M )*+
+< J 9 5 .
$ $ +
! B < $ 9 5 &G+ ) %A
.=" 5A&+ Z 7 J + N
E+ ! + ! =" ( 2 "
. ) M %+ + ž š
BJF
! %&- EH %T Y+ E F 5

!)
< +
7
( M OK
next &! [M .( *- &
name caption %>7
name

caption .

+ . =" ( "
+
!
- + !(
& ! =J JH . ! M
+
+ ! + .
7
N
<7)
- + . ! %H X < @ < +
-9

http://www.ehsani.org/jooti/

n+1

40

6

„H.

$ $ !
-> &! [?"
%+
.
F

+
$ !
%+
! ok . . ! E &A
.)
+
! select %+ < +
.
H.
F š ````ND
- ) E7
-9
.=" %T < + E
%+ < + !
.=" ( ! : < $ B
-&+%
+ %H X
!< T + G
%X 7 %> %+ G2+ 4- ) !
+
9. # A <
« @ < .
A+( 2" $B 5 )
! : $) - - $
(
+ )
& H)
+ ND caption ! =" %F ! ( ! : B
! . $ ND mnuSep1 - + %$ ,T
- . ! ( G +) –
.=" (
&
:
<
Q,+ ) ND
+ I + )
7- + >! N ! 4 <
ND <
%A (shortcut) 7- + < $ >! (combobox) = T )
!
+5 < N !
>! - + -9
7- + >! ND . „ H . ! Q , .="
: Checked
=L
4 + 5 < . ! E&0 checkbox
7
- + +
= L 5 ²9F C M Œ A < . ! false true ND checked
. ! true
+
checked N
+
true
( & J " K )!
& )
& PopupMenu
„ &@+ BJF - - %>L < + %H X % 2 ( G: < $ +
)
( G: < + %
<
A-D < .
- visible
!% + -ª
ND < G- &. D ! . ! ( 2 " form.popupmenu
) + A
- + ‰ < $ setting I (top level menu)
$ ,+
yI * +)
-D + ! < ŒJ- x I B"
ˆ#
) ="
V +
,+ ² F C M
,+) * + )
-D + ! < ŒJ- \- M
+)
D
! A N &. D 5 D (.="
N !
>! E
*+
- (bold) \- M ! %& D „ &@+).
(.=" %" " E
$ ŒJ- ND
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

If Button = vbRightButton Then _
Form1.PopupMenu mnuFile, defaultmenu:=mnuFileOpen

End Sub

!
<

P + < m+ < + $ + 5
5 < :< š Zžš
. OY+
2+ - *+) !% :
- +
< +
* + ) listbox <
.
+
* + ) picturebox
! ="
-. :< +
! $ < =" %F ! .
P
. ! C L ND R + 9 mousedown
:&
M 9&
%+ )
+ click
+)
!
>! F
+<
.
. - + ! =" Œ- &$ $ ! "
http://www.ehsani.org/jooti/

41

n+1

6

:
.=" G+
9 % A: $ + %H
ND - < G !)
< P ( M ="
+
.
.
( hOX
!
T +5
$ +
”...“
(h &+ space)
! ( 2 " &>!
) %>L < $ + - <
. ) - %+ ( 7
! < &>!
< G+ - N #
! $ <)
P+) =" File * &$ ˆ# =&" ) + 5 T
+5 )
D 5 D * &$ exit < + (
Game +
. *+ : $
D ") B
="
! =" ND
D5 D about =" + 5 D help < +
N *!
... = %?! N
- +- (
% 0OX
. $ +
. ! = 0 * &$
- " < $ 7- +
- " <$ +
( !
0 ND
! N # . =" ="
A + &$ ! < !)
(.="
:
. ! %H X +
- m
!% $ +-

http://www.ehsani.org/jooti/

6
X
1.
2.
3.

.4

5.

<

n+1

42

&
< P

<$(

2A
M

$ +

6

0 O L1M : N )*+

Š

%>7 < $ + - E F 5
. A + F š G-D

P M O L1M : 1-6
-

+ ! .="
! R 7 < ( " < $ ( ) %A Š M ( M
+
! = @š N hOX
5 F .I "
N " M<
ET
M( M !
:
* &$ + . .
( 2"
+ BJF $ •" M ND
!
A+« +
!<$ ! A
=H ! %-„ X
) < $ Š M .=" Q >Œ+ G+ < Œš
. A + %7 0 % H
:( 2" U
)
) * &$ $
%+ . -9
0N ! M +< "
+- +( „ !
( A+ M
0V H3
!N+
! * + <9
D
( -) N +
<)
.
Private Sub Label1_DblClick()
MsgBox "RndNum is " + CStr(RndNum)
End Sub

: msgbox < $ + M
. * + ( C &- Š M 7@:
! % + : Prompt
J+ ) %0 & + %A - + ! Š M ( M <( $) &! : Buttons
:
)
Constant

Value

vbOKOnly

0

vbOKCancel

1

.

vbAbortRetryIgnore

2

& '

.

!

& '

Cancel

#

Ignore

#

OK

" #

OK %

Retry ( abort %
.

vbYesNoCancel

3

& '

Cancel

#

No (Yes %
.

vbYesNo

4

vbRetryCancel

5

.

!
& '

No

" #
#

Yes %

Cancel

Retry %
.

vbCritical

16

(

# 2))

*

#

+,
.

vbQuestion

32

vbExclamation

48

vbInformation

64

.
.
.

http://www.ehsani.org/jooti/

!

!

" #

& '

#

" #

- ./0
& ' #
4# , 5 67
89# 5 67

,

:6;# 5 67

n+1

43

0

vbDefaultButton1~4

> 4 #

6

?# < +'
@

0

vbApplicationModal

#

4096

vbSystemModal

%
.
C,
E

=>
AB

?# !
@ D

C,
@ D

#
#

" F

G

#

.

H
%#

<
$ EA 5 . ! =
Š M ! < $ EA ) ( 2 "
+
%H X < 4 + N &$
J
G-D )
! $!
- + - %P *
< $ = @š < BJF ! vbCritical L ,+ .(
2. ! - (
ND =7 ! = " H ND )
) ( 2 " =" %- m @
.
%&- $ &
+m+ G 5 ! A + !
.=" (g M *. ! Š M ( M N 0 : Title
‘(
&!
!
ŠM( M
ND ) ±
<
!)
$ ,+.
C &- + ! !< +$ +
- U) +D 4 & BJF
!5 )
P
(.
- C" M <) - ( A- C
ND < "
Private Sub Form_Unload(Cancel As Integer)
If MsgBox("Are you sure to exit?", _
vbQuestion + vbYesNo) = vbNo Then Cancel = True
End Sub
$
buttons < $
,*+ ) %¶@ N +
!(
%+ .="
" =+O0 YesNo % @+ „
. ! •&: 9 - $ vbDefaultButton1~4 ) %A
Constant

Value

Description

vbOK

1

OK

vbCancel

2

Cancel

vbAbort

3

Abort

vbRetry

4

Retry

vbIgnore

5

Ignore

vbYes

6

Yes

vbNo

7

No

(
I

F<
% *.
M !5
integre Š +
.

!

Œ- &$
Y+
! •&:
ND
: Š M % *.
J+
) ! $ &! )
! $
. - P+
J+
&!
BJF N #
J+ N ! ( Å <) ) - . + 7- Š +
ND - +
!
! ( Å VbMsgBoxResult

Private Sub Form_Unload(Cancel As Integer)
Dim ret As VbMsgBoxResult
ret = MsgBox("Are you sure to exit?", vbQuestion + vbYesNo)
If ret = vbNo Then Cancel = True
End Sub

http://www.ehsani.org/jooti/

n+1

44

6

H
F ! * + %F %- +)
5 unload
5 . * + ŠT F 5
! true cancel Š + . =" N
.=" false ² F C M Œ Š +
! G *
# $ .=" N
( G@ C, 5 < 5 & ¡ X
. A+(
%A
:5 &
.
P
! ) new game) E7 < ! <)

A

O L1M : 2-6

!=" 2+
! %>7
$ %&! $
%+ ! % <
) %A N ) (!
- „ !) ( 2< ! <)
$ ( M 5 ) %A
< ! =0 " ( ( ! %H X „
.(!
P + „ !)

( M5
- + OY+
!) $ +
P
!)

Dim ret As String
ret = InputBox("enter ur name", "cowboy", "10")
If IsNumeric(ret) Then
If ret < 2 ^ 16 And ret > 0 Then Timer1.Interval = CInt(ret)
End If
: msgbox defualt N &. D BJF =" msgbox

7 ND < $ N &. D
(
-( M
! =" %š 2* M J+ N &. D 5 .
R . $
& %>@F interval
ND - + & .="
+ +!
U
"
0<
! . ! =" 5 <
. *- (runtime error) : N +) < Œ
#
+ %
$ ´ - ! =" Q %>7 <
2. E T 5
+ I
ND <
- +
! %7" +
!
.
Q,- 5 G
+ %¶@

A0Q R
I E F N ! ( Å ) < «> ,+ < $ + !%
G
( !=
. . (
A + ( 2 " \<$³ T
9: $ ³ T 5 ‘= # C> T .
$
.
! ( 2 " G-D )
- +9- +
$)
(ctrl+T) ! Q , - components...
-9
="
>!
Q , - Microsoft Common Dialog Control 6.0 * + )
.

$

C +)D

: 3-6

$( M &H
=- F Q , $ - + &$
- "
9 7@: <
!%
T
. !
m2L < %A I
%+ F š 9 7@:
9 5
.=" % + - : N +)
&
-+ 9 5
open dialog : 1-3-6
&!
: 9 5
$
m2L < label
. !
:
) ! &!

http://www.ehsani.org/jooti/

n+1

45

6

Private Sub Command1_Click()
CommonDialog1.Filter = "All Picture Files|*.jpg;*.bmp;*.gif|JPG only|*.jpg"
CommonDialog1.ShowOpen
Label1.Caption = CommonDialog1.FileName
End Sub
) | ) E7 . ( C &! % $ E F ( ! 5 @ : Filter
ND ) @
* + ( N *- E F =+ F 5 <
! %+ ( pipeline
)
- *+ : $) ;
! ( C &! % G> F
... pipeline
7L B 5
+$ + N *- E F N ! ) ( M : Showopen

.
9 5

! B"
!U

.
(
Q,- E F -( EA
%
Š ( ,T

CommonDialog1.Flags = cdlOFNHideReadOnly
. * + K H readonly &!

) %A (

M5

+

.="

(

.

M

A+

: FileName
- + : Flags
Y+ < . !

showopen ) E7
.=" open - + J
9 - save
FontDialog :2-3-6

! M < $ \T ) > Q , - (
:
="
) \>F
.C &- m2L PM # < $ =- F C &- < cdlCFBoth
. PM # < $ =- F C &- < cdlCFPrinterFonts
.C &- m2L < $ =- F C &- < cdlCFScreenFonts

http://www.ehsani.org/jooti/

M
"

1.
2.
3.

n+1

46

4 label <

=- F

6

,*+ ! 5 .=" ( +D

)

- &- !
. A+

Private Sub Command2_Click()
CommonDialog1.Flags = cdlCFScreenFonts
CommonDialog1.ShowFont
If Trim(CommonDialog1.FontName) = "" Then Exit Sub
Label1.FontName = CommonDialog1.FontName
Label1.FontSize = CommonDialog1.FontSize
Label1.FontBold = CommonDialog1.FontBold
Label1.FontItalic = CommonDialog1.FontItalic
End Sub
# +! cancel
! . ! =" 5 < (
( 2" R
L ) *- Œ
(. * + ” “
fontname
J+ N ! cancel
. A+K H
K X %T < $ >L F trim "
color dialog : 3-3-6

BJF !=

- )„

* žš

. ="

&$ )

( " \- Q , . - &-

Private Sub Command3_Click()
CommonDialog1.ShowColor
Label1.ForeColor = CommonDialog1.Color
End Sub

EA

I < ! EA
!
. !Q,- U

$

:

N A+ 5 cowboy + !
+) \7 \"IV + " !

T AF +
-

&-

E+ !

Q

)

U : 4-6

- " < $ F ! $ J# $
!( D
+ < $) - &
5 "D N +
! * + )„
„ H 5 &$ ) [M . -9 „
! -9 „
N $ 5 "D
I
!)
0N ! M +add form
project < +
!< ( M) . !Q,Q , - Form
9. * + )
.
!
F ="
: F
ND OY+ .
+&4
@
%F
0 ( m+
F 5 %H X
7- . ! 4
N ) V H < ) + @F
: $ + •" M •
" # BJF .
%>A*+
‘ $ C &- < P
F - P# .1
. ! %+ ( 2 " show + ) P
F
C &- <

http://www.ehsani.org/jooti/

n+1

47

6

Form2.Show

!
: F
- + $ &
: + MN
+5 .
%+ F BJF
! L vbModal + M
. + %&
F
$
!
!
A + 7L ( ! L ND ! %+ F
A+ !(
) () !
.
&
F ND

7
F
- P# .2
%2,+ = + Œ
F
$ ,+ .
. ! ( 2 " Hide )
< $ Š + &0 ! * &- /0 + A + m+
F " 5
. " N M (5 + 7@:
5 + - +) ND %+ &0
Form2.Hide

-

5 ) ND < $

Š+

O+ !

Unload Form2

F

$
%+ .
! ( 2 " unload )

Unload Me

.

$ ND

N„ &
! =" %+ F P
- me %
. A + unload
F I F <„ X &!
‘ ! EJ + P
F
F
) < J+
- P# .3
ND %+ &0 < $ Š + < $ 9
F - N ! !Å N +
! M %" "

Form2.Text1.Text
Form1.MinReng
%+ cowboy & 4

) %&

! T

+N

5

<

-

Form 1 :
declaration =&
public MinReng as integer
Form2 :
Private Sub Command1_Click()
Form1.MinReng = CInt(Me.Text1.Text)
Unload Me
End Sub

(

- ND < $ Š +
±
Å F N &$ < Š +

4F H )
)„

Form 1 :
private MinReng as integer
Private Sub Command1_Click()
Form2.Show VBModal
MinReng = Cint(Form2.Text1.Text)
End Sub
Form2 :
Private Sub Command1_Click()
http://www.ehsani.org/jooti/

F A ) E7
F ! % $ J+ . A+

n+1

48

6

Me.Hide
End Sub

.
.

( ! ( 2 " ND < $
%+ EA*+ #
="

&4 <

.

Š+)

$cowboy <
!

%+ F

! ="

<
.

( ! %2,+
F <„ X &!

:

FI

.

! E+ !
G inputbox ND )
F

! « @ (new)

Dim x As New Form2, y As New Form2
y.Show
x.Show

http://www.ehsani.org/jooti/

FU
F .
:

5
,*+
&4
!
!

:
< ) : P$
:% &$
: F
$
%+
: ( . ! •" M

n+1

49

A
+-

!

6

2

F .

: V0 )*+
J-D

.<$E F
.
<
!
&$ !
! %+ ( 2 " $ < : < $ 9 ) + - 5
7T
$N
+$ , + & H . ( ! ! G-D )
&
... richtext status bar toolbar - + % $ 9 . ! ( 2 "
5 @T Œ+ ) E7 =" G
* + * N + ! =0 " E F 5 )
.
(
< F H %>7 < $ E F ªT Œ+ E F

MiniWordPad
Microsoft

Microsoft Rich TextBox Microsft Windows Common Controls
. ! Fš N
(g M components
Common Dialogs
E ND ‰
(custom) <
$
m2L < ImageList
5+C
+toolbar <
)„ < $ [A0 . !
>!

< "=

-

)

! F š ND

(. -9 <VisualStduioDir>\Common\Graphics\Bitmaps\OffCtlBar\Small\Color

=" ImageList1
ND Image

ND ImageList
! Fš
F toolbar
[?"
! F š &!
$ [A0 )
! $<
!
[ toolbar
$ combo
. ! F š imagelist
. $ ‰
ND placeholder
ND ) N A+ . $

http://www.ehsani.org/jooti/

n+1

50

.

! %H X
$ C &-

$

6

)„ < $ +
! F š $ richtextbox
" < $ =- F = T $ , + combo ND

Private Sub Form_Load()
Dim i As Integer
For i = 0 To Screen.FontCount - 1
Combo1.AddItem Screen.Fonts(i)
Next
End Sub

. ! Š ND richtext =- F
Private Sub Combo1_Click()
RichTextBox1.SelFontName = Combo1.Text
End Sub
5 + «> ,+ < $ @Œ ND
<

combo

.

: !

Q , - G-D ) %A

.

N

+ ! =" % + 7@: RichTextBox
.= - «> ,+ < $ =- F
)
A
underline italic bold < $ &! &
! F š ND \Š < %A =- F () Š

Š 9 - richtext () -

Private Sub Form_Resize()
RichTextBox1.Width = Me.ScaleWidth

http://www.ehsani.org/jooti/

A+

Š

F () - %

n+1

51

6

RichTextBox1.Height = Me.ScaleHeight - 300
End Sub

.

- ND < ! B m+ h 2
F h 2 KO
ET
300 0
. ! $
< . () >L F 5 @ E F
. *- A# ! % ,*+ H )
F () - !
!< ! &
H
true ND checked ! $
toolbar <
9.
view < +
.

Private Sub mnuViewToolbar_Click()
mnuViewToolbar.Checked = Not mnuViewToolbar.Checked
Toolbar1.Visible = mnuViewToolbar.Checked
RichTextBox1.Top = IIf(mnuViewToolbar.Checked, Toolbar1.Height, 0)
End Sub
. *+ªZ
$ ´ toolbar + 5 N !
>!
Edit < +
<
AutoVerbMenu
- + 7T .=" paste cut,copy E+
+5
-9 + ="
>! 9 5 < %
! True
RichTextBox

+5 N
- +
)
$ , + + ‡-D 7 % +
. A + ="
"
N
richtext 7- + < $ >! 7T . ! ="
%>A*+
! %&- ( 2 " $ >! 5 ) N
!% $ 9
%T
.
<9 # - + < + - $ ! 7@:
=J JH Windows clipboard
( 2 " ND ) $ + " U
. $
ND = + Œ
. !
.=" %
9 - Clipboard
Private Sub mnuEditCopy_Click()
Clipboard.SetText RichTextBox1.SelText, vbCFRTF
End Sub
Private Sub mnuEditPaste_Click()
RichTextBox1.SelText = Clipboard.GetText(vbCFRTF)
End Sub

(

„ &@+ - * + h

.

cut [M ) N

sel

.

! %L
$(

A + AF
:< š Zžš
( select) Q , - 5 +
: Clipboard

.1 SetText
. . %+ ! ! %+ %T
+ M
clipboard % + C,
< 05+h -) ! A+5 @
5+h + M
! =" ( Z =- F
,*+ <
=+ F 5 ) RichTextFormat
(.
,*+ 5 < 0 5 +

2. GetText
settext
+

M

- + ND

+ M. -

. %+

http://www.ehsani.org/jooti/

clipboard 5 + C,

.="

n+1

52

3. GetData
VBCFBitmap : ND < $ =+ F .
4. SetData
5. Clear

. A+
%+ #

-

P+
clipboard
.=" VBCFMetaFile

P + ! %T

! :

6

C,
VBCFDIB

+ M

clipboard N
clipboard.clear &

C,
! %T
%

<
! .

File < +
Private Sub mnuFileNew_Click()
Dim ret As VbMsgBoxResult
ret = MsgBox("Do u want to save the changes?", vbYesNoCancel, "MiniWordPas")
If ret = vbNo Then
RichTextBox1.Text = ""
ElseIf ret = vbYes Then
mnuFileSave_Click
End If
End Sub
Private Sub saveit(Optional fname As String = "")
CommonDialog1.Filter = "Rich Text Format|*.rtf|Text File|*.txt"
If fname = "" Then
CommonDialog1.ShowSave
sFileName = CommonDialog1.FileName
Else
sFileName = fname
End If
If Trim(sFileName) <> "" Then
If Right(sFileName, 3) = "rtf" Then
RichTextBox1.SaveFile sFileName
Else
RichTextBox1.SaveFile sFileName, rtfText
End If
End If
End Sub
Private Sub mnuFileSave_Click()
saveit sFileName
End Sub
Private Sub mnuFileSaveas_Click()
saveit
End Sub
Private Sub mnuFileOpen_Click()
CommonDialog1.Filter = "Rich Text Format|*.rtf|Text File|*.txt"
CommonDialog1.ShowOpen

http://www.ehsani.org/jooti/

n+1

53

6

sFileName = CommonDialog1.FileName
If Trim(sFileName) <> "" Then
If Right(sFileName, 3) = "rtf" Then
RichTextBox1.LoadFile sFileName
Else
RichTextBox1.LoadFile sFileName, rtfText
End If
End If
RichTextBox1.Refresh
End Sub
Private Sub mnuFilePrint_Click()
Printer.Print RichTextBox1.Text
Printer.EndDoc
End Sub

$ Printer !
- 5 + enddoc ) [M .=

(

P
A- 5 Printer
+
- ND < N + =" %
. * + Ð # printer
toolbar +

Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
Select Case Button.Index
Case 1:
mnuFileNew_Click
Case 2:
mnuFileOpen_Click
Case 3:
mnuFileSave_Click
Case 5:
mnuFilePrint_Click
End Select
End Sub

< +

>!

U

&! [ - $ <
‰ ,+ ! A

BJF
! %(.= - ND

http://www.ehsani.org/jooti/

-< ) !
F ND R +
R + % + .)

n+1

54

. ! ) =- F 4 <
5 + &$ =- F ! $
.(

6

:
FontDialog !
! F š % + .1
+=- F 4 < %
2.
Q , - C, BJF - ! ² 0
:

... toolbar

http://www.ehsani.org/jooti/

+

%

J- + -

n+1

55

C
N

9
&

7@:

6

Z windows

M : N0 )*+

A+ #
) 9
ND ! $ , + N D)

N T9 +
- .

%
²
P+
. $
.
$ C windows
N
D
8
DLL

5 . - (
-CN )
! =" %@
<
)
9
)
<$
) ( 2" < .
. %+ Windows API G-D
« @ 5
N+
+G-D « @

5
- E+
.="
ND •
! < DLL - ND < G- &. D I •
Y+ <
=" SndPlaySound ND - ! )
< $ API ) %A « @
:=" ( +D )
winmm.dll
Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA"
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
5 7- E2>F)
! ( P- BitBlt =" ( ! t . %-„ X
A + AF .

(!(9

#

Public Declare Function BitBlt Lib "gdi32" Alias "BitBlt" (ByVal hDestDC As Long,
ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As
Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal
dwRop As Long) As Long

: %A 5
Public Declare Function StretchBlt Lib "gdi32" Alias "StretchBlt" (ByVal hdc As
Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight
As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long,
ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As
Long
Add-ins\Add in … < + .=
- G N ! °2H <) - - ,7
EA
-+
manager
<$
9. VB6 API Viewer <
Q , - LoadOnStartup Loaded

.

$ constant !

8
9

.

+ N &$ . !
ND API Viewer (

9.
E F ND
. ! :
„ H . ! load Win32API.txt
Q , - Declares
70 combo
! $ API ) %A - <
!
!
>! E ( +D )
$« @
.
7
ND « @
: 9 - Types Constants < $ C, API Viewer
$)
< $ api (
( 2 " < $ type

Dynamic Link Library
Windows Application Programming Interface

http://www.ehsani.org/jooti/

.

n+1

56

6

SND_ASYNC = ¯

sndplaysound « @ =" %F ! % # + J+
• « @ !
!= ). ! Fš N
F declares C,
(.
Private
F
Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA"
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Private Const SND_ASYNC = &H1
' play asynchronously
Private Sub Command1_Click()
sndPlaySound "c:\windows\media\chimes.wav", SND_ASYNC
End Sub

ND N N M < .
%+ C,M E F
=" E F V D .
• 5
7- MSDN . ! L %T E F • 5 &$ - +
N )
$ API < $ & $ Y! - 2" + I - ,
ND < & $
P
.=" =," %&! VB N
- +- < 5
.=" C
$ API

-

+

$ &

$

windows N

! Restart
- - +)
!< ! $
.N ! restart $ %A . $
-

Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long,
ByVal dwReserved As Long) As Long
Private Const EWX_LOGOFF = 0
Private Const EWX_SHUTDOWN = 1
Private Const EWX_REBOOT = 2
Private Const EWX_FORCE = 4
Private Sub Command1_Click()
ExitWindowsEx EWX_REBOOT + EWX_FORCE, 0
End Sub
Shutdown,Reboot(restart) .
! =" < !
E&0 ND < 7: h •&: ewx_force
! G-D )
! $

+ M
logoff

E&0 - + $ + - $ 5 )
! $< 0h - . *+E 7
.= - N ! ŠT E < 7: h - +
! ŠT )
) N
±
F
m+ 0
)
%
$I
$ : HWnd
>" % N ! L<
=" % ND - - + 0 5 . * +
- +
N
+%
. .
) - 05
$API
.
P
ND
$ object.hwnd

Private Declare Function EnableWindow Lib "user32" (ByVal hwnd As Long,
ByVal fEnable As Long) As Long
Private Sub Command1_Click()
EnableWindow Text1.hwnd, False
End Sub
) $ . . ! @F Z
@F window
N + EnableWindow
9 # &$ windows
!
P
F %+ F
window - N
.textbox
% H =" window

http://www.ehsani.org/jooti/

n+1

57

2 ‘= #
% @ TextBox
H A+ !
: (

#=

6

! ( 2 " Text1 Enabled ) A
API 5 ‹ F +
%>L
- $ + = &$ wnd API 5 ! =" 5
$ api 5
$ < P window $
$ &
.
!
7- &
+$ ND .
- + +! window
$ N D =" <
: =" ( +D )
G-D ) %A

Private Declare Function EnableWindow Lib "user32" (ByVal hwnd As Long,
ByVal fEnable As Long) As Long
Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long,
ByVal yPoint As Long) As Long
Private Sub Command1_Click()
Dim ret As Long
ret = WindowFromPoint(0, 0)
EnableWindow ret, False
End Sub
! < ( M
$
. %+
,+
(WindowFromPoint) API 5

N

%&! C +)D

-

). -

. %+

: m2L

="
,+ ND N„
(! ! ="
"
V +

,+ 5 F .

Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As
Long
Private Type POINTAPI
x As Long
y As Long
End Type
Private Sub Timer1_Timer()
Dim pt As POINTAPI
GetCursorPos pt
Label1.Caption = pt.x
Label2.Caption = pt.y
End Sub
windows

N

: window
5+5F .
+ ! =" % $ ! 5 9 P- N $ ) %A ! 5
.
-

Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As
Long
Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long,
ByVal yPoint As Long) As Long
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 Function SendMessageString Lib "user32" Alias "SendMessageA"
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal
lParam As String) As Long
Private Const WM_GETTEXT = &HD

http://www.ehsani.org/jooti/

n+1

58

6

Private Const WM_GETTEXTLENGTH = &HE
Private Type POINTAPI
x As Long
y As Long
End Type
Private Function GetText(wnd As Long) As String
Dim buf As String, l As Long
l = SendMessage(wnd, WM_GETTEXTLENGTH, 0, 0)
buf = Space(l)
SendMessageString wnd, WM_GETTEXT, l + 1, buf
GetText = buf
End Function
Private Sub Command1_Click()
Timer1.Enabled = Not Timer1.Enabled
End Sub
Private Sub Timer1_Timer()
Dim pt As POINTAPI, wnd As Long
GetCursorPos pt
wnd = WindowFromPoint(pt.x, pt.y)
Label1.Caption = GetText(wnd)
End Sub
+- 5 N
DialUp Networking (
M<
.
windows9x . L

7! C +)D
: GetText • ž š
. - P+
$ 5 5 + X sendmessage 5 T
. - P + space
@ ND <
P + N &. D
space
"
+ =" • N &$ ) < P
- =J JH
! sendmessage 5 +
. $ +
buf Š +
P + 5 + I="
ND D N &. D
%@
X ) * %A E T 5
="
X ND " N &. D
+ .=" (NULL) 2L %A" ! ! !
D ! !C
! ="
.
+
! !5
$
%&I=
dc

.

$

F . % : . .=" )
A + ( 2 " GetDC(hwnd) •

F BorderStyle I $
! Maximized

N
F

!
,+ .

%

J=J JH : HDC
) hdc 5 F . < .= $ $ dc
.
P
wnd
: m2L ) 5 F . [A0 + F ) 0,0
,+ picturebox
windowstate
! 2L
picture

Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As
Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal
hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As
Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long

http://www.ehsani.org/jooti/

n+1

59

6

Private Const SRCCOPY = &HCC0020 ' (DWORD) dest = source
Private Sub Form_Load()
Dim wnd As Long, dc As Long
Picture1.AutoRedraw = True
wnd = GetDesktopWindow
dc = GetDC(wnd)
Form_Resize
BitBlt Picture1.hdc, 0, 0, Screen.Width / 15, Screen.Height / 15, dc, 0, 0,
SRCCOPY
End Sub
Private Sub Form_Resize()
Picture1.Move 0, 0, Screen.Width, Screen.Height
End Sub
Private Sub Picture1_Click()
SavePicture Picture1.Image, "c:\test.bmp"
Unload Me
End Sub
. A + " P dc
<

! $

Š

ND

-

+

dc

(

<

bitblt •

: F EA N
F E Π+ EA

Š
) .

Private Declare Function CreateEllipticRgn Lib "gdi32" (ByVal X1 As Long, ByVal
Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long,
ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Dim rgn As Long
rgn = CreateEllipticRgn(0, 0, Me.Width / 15, Me.Height / 15)
SetWindowRgn Me.hWnd, rgn, True
End Sub
A + « @ EA %¶ Æ m+
CreateEllipticRgn •
< $ api (
. $ + ¯ window
( m+ ND SetWindowRgn

.

CreatePolygonRgn
http://www.ehsani.org/jooti/

! · Jm

)

n+1

60

6

CreateRoundRectRgn
CombineRgn

(

Å<
+-

: INI < $ E
*
!
$ % + < G> F ) %L h - ini < $ E
4F H N ! = J <
. - + A +&4 N
. - ¯

F
F
!
+

Private Declare Function WritePrivateProfileString Lib "kernel32" Alias
"WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal
lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias
"GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName
As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize
As Long, ByVal lpFileName As String) As Long
Private iLeft As Integer, iTop As Integer
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Dim buf As String
buf = Space(255)
GetPrivateProfileString "myAPP", "Left", "10", buf, 255, "testini.ini"
iLeft = CInt(Left(Trim(buf), Len(Trim(buf)) - 1))
buf = Space(255)
GetPrivateProfileString "myAPP", "Top", "10", buf, 255, "testini.ini"
iTop = CInt(Left(Trim(buf), Len(Trim(buf)) - 1))
Me.Move iLeft, iTop
End Sub
Private Sub Form_Unload(Cancel As Integer)
WritePrivateProfileString "myAPP", "Left", CStr(Me.Left), "testini.ini"
WritePrivateProfileString "myAPP", "Top", CStr(Me.Top), "testini.ini"
End Sub
: notepad
+ + - ini E F ) % A0

<

!

ini E F

A- 5 @

$5

V D filename =&
.
. * + ( Å windows
!

http://www.ehsani.org/jooti/

F

ini

! %+ P $

n+1

61

6

\- &!
\- &! ini < $ E F
)
windows95 ! %
)
7
4) <
: . - <
:
<:
.
- %+ ND
&4 $ +& ! =" ³ 9 ini E F
. ! ( 2 " $ api ) vb
" ) - +<
:
!<
"
A + 2 ! vb
Private Sub Form_Load()
Me.Left = CInt(GetSetting("myAPP", "Position", "Left", 10))
Me.Top = CInt(GetSetting("myAPP", "Position", "Top", 10))
End Sub
Private Sub Form_Unload(Cancel As Integer)
SaveSetting "myAPP", "Position", "Left", Me.Left
SaveSetting "myAPP", "Position", "Top", Me.Top
End Sub

< : &$ N &- G-D
+ .=" =H
" 5
!
=," <
: < $ API N ! ! ² 0 . = - <
:
! A+ . &
=," < $ ! &$ 5+ ="
+5
Y! <

!% G !
ND

!

MSDN

2+ + -

$ API

+

*
@T Œ+ <
. ! @: + = $
9 - http://www.allapi.net/ = "
.
žš
Y+ )

:5 &
password username
) Connect To ( M ( . $ ! < + - .1
. !( ÅE F
52> ( &
(stretch).
picturebox () ! # !
m2L
2.

http://www.ehsani.org/jooti/

n+1

62

(winsock.ocx)? T

6

\]

: F )*+

+- E F5
%T ?+ !
< BJF + < $ + C +)D < . A + ! 9 +
?+ ! #
<
!
+% $
! =" %F ! BJF
?+ !
<) - $ + - 5 N !
.
9 +
+!)
$ ,+ !
(
2 + + 9T -) + #
=J JH
R7 5 +
%X 7
9
) - %X 7
$. !
R7
$
. -9 + Y+ 52>
"
52> winsock 9 R 7 5
.=" + %>
( & Port 52> ( & IP(Internet Protocol)
$
!)
Microsoft Winsock Control 9 G-D
. ! Fš
F . ! frmServer < P
frmClient %A
. $
winsock
5 + 7@:
&!
frmClient
F
. $
winsock
5 + 7@:
9"
.
P + (Client/Server) 9P +
/ < *+ ]+ - I + +5
9P +
' A + R 7 ="
9P +
) < *+
"5
5 ) . *+
R7
A+
="
=JF +
L
=F
N " FV"
9 # &$ R 7 N ! •Œ N +)
4mT
< *+ )
! $ K X $ ) - + R 7 •Œ .=" Š M N !
.
9P +

="
4 + 9P +
- P#
Private Sub Form_Load()
Winsock1.LocalPort = 10300
Winsock1.Listen
End Sub
) %A
N+
(winsock)52>
+‘
X,
52>
Y+
<$( &
10300 %>
( &
B
! EL (port)%>

B . A- ( 2 " $ 52>
"B ) !
!=
. A+Q,) &H
80 - + % M + .
$ %T „ &@+ 1024 <„ < $
(=" webserver R +
M 5 ) ="
Š*+
U . . A + EL (
Q , - %>
B
+ 52>
B
. - + %+ 52> \-)
‘ !R7

="

Private Sub Command1_Click()
Winsock1.Connect "127.0.0.1", 10300
End Sub
Private Sub Command1_Click()
Winsock1.RemoteHost = "127.0.0.1"

http://www.ehsani.org/jooti/

< *+ - P# •

n+1

63

6

Winsock1.RemotePort = 10300
Winsock1.Connect
End Sub

$ ,+
[M
(
EL < A7
= ?+ ! 5

! =" < ?+ ! (IP address) 52> ( &
B
! :
?+ !
<
+$ +.
E + ND
5+ - + . .="
?+ ! N &$ IP V D ( & 5
70 5 . %T ="
0 5 &$ $ & IP „ & H
&$ IP V D Winsock1.LocalIP I
="
ND - +
. - P+
- + !. !( 2" 9" - ) - + IP <
- + N
?+ ! HostName .
www.yahoo.com - +
.
=" winsock1.LocalHostName
$ ,+ &
!< +! =" < port ( & Remoteport
.=" \-) U . -D
E +
. " F %+ (
2. V D
& ="
Connect

+
ND

‘ !

(

=F

="

" - P# •

Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
If Winsock1.State <> sckConnected Then Winsock1.Close
Winsock1.Accept requestID
End Sub
%+ ‹ 2 ConnectionRequest
" +
" ="

ND

!

J+ ) <

@ =" winsock %>@F = @š ( $ N *- State
:
%+ 5 M

Constant

Value

sckClosed

0

sckListening

2

sckConnecting

6

sckConnected

7

sckClosing

8

sckError

9

A + º,*+

%
. F

žš
%X 7
.="

I² F C M
.= -

4 + I\-)
R7

<

H

(
R7

U .

R7

N ! •Œ

H

.( +D C M Œ

P + ! < J+ .
.=" (

. A + •Œ
R 7 Close
A+ 7
="
Accept
="
( &
!

" 2 ( Š M)

Private Sub Command2_Click()
Winsock1.SendData Text1.Text

http://www.ehsani.org/jooti/

0OX

- P# •

n+1

64

6

End Sub

(

" F
! =" % 0OX !
< *+
+ ). " 2 + R 7

P+ + M
senddata
"
E J+ K X
ND .
(. A &- % F 9P +
! =F
Š M - P# •

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim mydata As String
Winsock1.GetData mydata, vbString
Text1.Text = mydata
End Sub

.
h -. $ +
! ="
0OX

%+ %F
5 " + % 0OX %
.=" ( " < $ =
@ E! Bytetotal
+ M Š+
P+
0OX GetData
X " + M
A+5@
+ M
0OX
.
( A- ( 2 " ND )
+
‘ ! •Œ
R7
- P# •
A + ( 2 " close + ) ! 5 <

<

.
(
:R7
$)

-

R7
.

0OX N " F • + !
!=
" $ , + . * + •Œ R 7 %
! \-) U . ND (
! 7

Private Sub Winsock1_Close()
Winsock1.Close
Winsock1.Listen
End Sub

N

+ H

. ! E 7 =#
!
: P

2, \]
$
- ! %* +)D + - $ < 9 P- N $
?+ !
)
< !
V
:<

Private Sub Command1_Click()
Winsock1.Connect "127.0.0.1", 10300
End Sub
Private Sub Command2_Click()
Winsock1.SendData "WinDir"
End Sub
Private Sub Command3_Click()
Winsock1.Close
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim sData As String

http://www.ehsani.org/jooti/

'

N
<$
D5F
*+

+
!
.
!

n+1

65

6

Winsock1.GetData sData, vbString
If Left(sData, 6) = "WinDir" Then Text1.Text = _
Right(sData, Len(sData) - 6)
End Sub

: 9P +

C,

Private Declare Function GetWindowsDirectory Lib "kernel32" Alias
"GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As
Long
Private Sub Form_Load()
Winsock1.LocalPort = 10300
Winsock1.Listen
End Sub
Private Sub Winsock1_Close()
Winsock1.Close
Winsock1.Listen
End Sub
Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
If Winsock1.State <> sckConnected Then Winsock1.Close
Winsock1.Accept requestID
End Sub
Private Function WindowsDir()
Dim buf As String
buf = Space(255)
GetWindowsDirectory buf, 255
WindowsDir = Left(Trim(buf), Len(Trim(buf)) - 1)
End Function
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim mydata As String
Winsock1.GetData mydata, vbString
If mydata = "WinDir" Then Winsock1.SendData mydata + WindowsDir
End Sub

º,*+ Š M
N N *- <
. - P+
9P +

BJF =" 7 %>7
! =F
Š M ND .
$ +
- ()
V
(( ! =F
! %+ Š
?+ ! N

< *+
!
+-

+ - N &$ %>
!5
P K X
*+( " F
D N ! M - +) %L
!
M N &$ OY+) ª" +
"

:
?+ !
IC

http://www.ehsani.org/jooti/

7
!
< +! # $. !
!

n+1

66

6

D

1

: C Cb

IF %X
: "

"
"

if condition then statement else statment

( P-D % ! UO . " =2. N
"%- &L5
!•

(ND

"

)

m+ N
Z %$
E 7 E
)%T
- !%
J+ < G 70 I
a<b - + <
(statement) " C,
.
"

)

+ <(

))
Y+
N 0
! NOF %- +
70 $ R
C,
P
- +
%T % *.
J+
. P+
" C,
$ , !% L
A + ( 2 " %! >
"

if condition then
statements
else
statements
end if

.

! %?! c

Š+

b

a

&

!+

: Y+
$ ,+

if a<b then c=b else c=a

J>H
J>H 5

For

.=" º,*+

@F

@

E&0

N !

A <

for var = start_index to end_index [step step_count]
statements
next [var]
$ ND J+ [?"
$ +
start_index
var Š +
$ ) [M . " end_index
A + F š step_count () ) var J+ A
P+ - * + :
"
var
J+ N
Š
.
(
* end_index
.
±
for J>H ) 0 + ) E7 N
+ exit for "
&
(exit for ) ( 2 " N ) < 0
J>H ! ! % L
.
$
end_index+step_count
J>H ) ±
) [M var J+
J+
- + J+ 5 I="
step_count < ² 2* M

.

9 - %2 +
: Y+
0 h & + 7" m+

L
for i=1 to 100
sum=sum+i
next

J>H
" < :
# J>H
:
"
While

) E7 J>H R
.="
. * &- : 9. $ J>H

R
7- ="

.

! %- +)
. *+

http://www.ehsani.org/jooti/

n+1

67

6

while (condition)
statements
wend
Do

J>H

Do [{While | Until} condition]
statements
Loop
J
Q , - while . .

%- +)

* + # J>H <
R
Q , - until . . A + E&0 while J>H - +
.
7R
! - *+ :
.
±
do J>H ) N
+ exit do

"

Do
statements
Loop [{While | Until} condition]

< : ) [M R
I
- loop ) [M %X
C, ! %
!. - *+ :
E H
" [M * + #
.=" %>7 =&
- + until while < >!

http://www.ehsani.org/jooti/

L
"
&>!