Академический Документы
Профессиональный Документы
Культура Документы
Visual Basic. Освой На Примерах
Visual Basic. Освой На Примерах
ru
90
. .
Visual Basic. . .: -,
2004. - 288 : .
ISBN 5-94157-521-1
Visual Basic
, .
. .
681.3.068+800.92VisualBasic
32.973.26-018.1
:
.
.
ISBN 5-94157-521-1
..
"-", 2004
www.WarezOk.ru
............................................................................. 1
I. .......................................................... 3
1. ............................................ 5
..................................................................5
2. ................................................................ 55
................................................................ 55
3. ....................................................... 99
................................................................ 99
4. .................................................................. 129
............................................................... 129
5. ........................... 141
6. ....................................................... 207
............................................................... 207
II. .......................... 227
7. ........................................................ 229
................................................................................ 229
Label.................................................................................. 231
TextBox ............................................................................. 233
www.WarezOk.ru
8. .............................................................. 257
Print...................................................................................257
Line....................................................................................258
Circle.................................................................................259
RGB.. ................................................................................260
9. ............................................................. 264
............................................................................ 264
....................................................... 266
.......................................................... 267
................................................................... 268
..................................................................... 273
10. .............................................................278
. -,
. . "Visual Basic.
"............................................... 281
................................................................. 283
www.WarezOk.ru
.
. , , .
, ,
, " ".
RAD- (Rapid
Application Development )
-
.
,
,
. ,
, RAD-, !
RAD- Microsoft Visual Basic,
,
. Microsoft
Visual Basic Visual Basic.
,
, .
,
.
Visual Basic .
. -
www.WarezOk.ru
, ,
.
, ,
,
Microsoft Visual Basic,
, ,
. ,
, ,
.
.
.
, .
. .
,
Visual Basic.
- ,
. . ,
, ,
Microsoft Visual Basic, , .
, ,
.
. ,
, . ,
, . . -
,
Visual Basic.
www.WarezOk.ru
www.WarezOk.ru
1
Visual Basic . ( ), .
(
,
Windows)
.
()
:
Label ;
TextBox / ;
CommandButton ;
heckBox ;
OptionButton ;
ListBox ;
ComboBox .
,
() .
.
www.WarezOk.ru
I.
,
.
/ ( TextBox),
( ListBox) ( ComboBox).
CheckBox OptionButton.
( Label) ( MsgBox).
, , , /, Val.
, ,
Format CStr.
1. " "
" ". . 1.1.
. 1.1.
'
Private Sub Commandl_Click()
Dim ms As Integer
' /
Dim kmh As Single
' /
ms = Val(Textl.Text)
'
www.WarezOk.ru
I.
kmh = ms * 3. 6
'
'
Label3.Caption = Format$(ms) + "/ - " + _
Format$(kmh) + " /"
End Sub
2. , 1,
" " " ".
. 1.1. ,
[/]
.
'
Private Sub Command1_Click()
Dim ms Integer
' /
Dim kmh As Single
' /
' ,
If Len(t1.Text) = 0 Then
' ,
' " "
Label3.Caption = " "
Else
ms = Val(Text1.Text)
'
kmh = ms * 3.6
'
'
Labe13.Caption = Format$(ms) + n / - " + _
Format$(kmh) + " /"
End If
End Sub
'
Private Sub Text1_KeyPress(KeyAscii As Integer)
' .
' ,
' . ,
' .
www.WarezOk.ru
I.
' KeyAscii - . 48 - 51 -
' 0 9, 8 - <Backspace>.
If Not (KeyAscii >= 48 And KeyAscii <=57 Or KeyAscii=8)
Then
KeyAscii =0
End If
End Sub
www.WarezOk.ru
I.
4.
(1 409,5 ). . 1.2.
,
, .
. 1.2. -
www.WarezOk.ru
I.
10
'
Private Sub Command1_Click()
Dim funt As Single
'
Dim kg As Single
'
' ,
' .
' .
funt = Val(Text1.Text)
kg = funt * 0.4995
Label2.Caption = Format$(funt) + " - " + _
Format$(kg) + " "
End Sub
'
Private Sub Form_Initialize()
' (
' ),
Coramand1.Enabled = False
End Sub
'
Private Sub Text1_Change()
' ,
If Len(t1.Text) = 0 Then
Command1.Enabled = False
'
Else
Command1.Enabled = True
'
End If
End Sub
'
Private Sub Text1_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
www.WarezOk.ru
I.
11
Case 48 57, 8
' 0 - 9 <Backspace>
'
Case 44, 46
' 44 - , 46 -
' ,
'
KeyAscii =46
' ,
'
If InStr(Text1.Text, .") 0 Then
KeyAscii =
End If
Else
KeyAscii = 0
'
End Select
End Sub
5. (/),
. . 1.3.
, .
. 1.3.
www.WarezOk.ru
I.
12
'
Private Sub Command1_Click()
Dim dist As Integer
' ,
Dim min As Integer
' ,
Dim sek As Single
' ,
Dim v As Single
'
'
dist = Val(Textl.Text)
min = Val(Text2.Text)
sek = Val(Text3.Text)
'
If (dist = 0) Or ((min = 0) And (sek = 0)) Then
Label5.Caption = " ."
Exit Sub
End If
'
v = (dist /
1000)
((min *
60
+ sek)
3600)
'
Label5.Caption = ": " + Format$(dist)
"" + Chr(13) + _
": " + Format$(min) + " " + _
Format$(sek) + " " + Chr(13) + _
": " + Format$(v, "0.00") + _
" /"
' Chr()
' Ascii
End Sub
'
Private Sub Command2_Click()
'
www.WarezOk.ru
+ _
I.
13
Unload Form1
End Sub
'
Private Sub Textl_KeyPress(KeyAscii As Integer)
' KeyAscii - ,
.
' ,
' 0.
' .
Select Case KeyAscii
Case 48 To 57, 8
' 0 - 9 <Backspace>
Case 13
' <Enter>
' :
Text2.SetFocus
Case Else
KeyAscii = 0
'
End Select
End Sub
' :
Private Sub Text2_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 48 To 57, 8
' - 9 <Backspace>
Case 13
' <Enter>
' :
Text3.SetFocus
Case Else
KeyAscii = 0
'
End Select
End Sub
' :
Private Sub Text3_KeyPress(KeyAscii As Integer)
www.WarezOk.ru
I.
14
6. .
. ,
.
. . 1.4.
'
Private Sub Conmandl_Click()
Dim sum As Single
Dim pr As Single
'
'
',
www.WarezOk.ru
I.
15
. 1.4.
If Option1.Value = True Then
'
dohod sum * (pr / 100) * (srok / 360)
Else
'
buf = sum
For i = 1 To srok
buf = buf + buf * (pr / 100)
' buf
dohod = buf - sum
Next i
End If
sum = sum + dohod
Label4.Caption = ":" +Format$(dohod, "0.00")
Chr(13) +_
www.WarezOk.ru
+ _
I.
16
" :
Format$(sum, "0.00")
End Sub
"
+ _
'
Private Sub Option1_Click()
Label2.Caption = " ():"
Label4.Caption = ""
End Sub
'
Private Sub Option2_Click()
Label2.Caption = " (.):"
Label4.Caption = ""
End Sub
7. ,
.
. 1.5. 1000 , .
'
Private Sub Convnandl_Click ()
Dim rl, r2 At Single
'
Rl R2
Dim r KB Single
'
' '
rl = Val(Textl.Text)
r2 = Val(Text2.Text)
If (rl = 0) And (r2 = 0) Then
Label4.Caption = " " +
_
" ."
Exit Sub
End If
www.WarezOk.ru
I.
17
. 1.5.
' " "
' " " ,
' .
If Option1.Value = True Then
'
r = rl + r2
Else
'
r = (rl * r2) / (rl + 2)
End If
Label4.Caption =
" :
"
www.WarezOk.ru
I.
18
Else
r = r / 1000
Label4.Caption = Label4. Caption + _
Format$(r, "0.00") + " "
End If
End Sub
' " "
Private Sub Optionl_Click()
' ,
'
Label4.Caption = ""
End Sub
' " "
Private Sub Option2_Click()
Label4.Caption = ""
End Sub
8. , , .
. 1.6.
. 1.6.
www.WarezOk.ru
I.
19
' ,
Sub Calculate()
Dim I As Single
'
Dim U As Single
'
Dim R As Single
'
If Option1.Value = True Then
'
U = Val(Textl.Text)
R = Val(Text2.Text)
If R <> 0 Then
I = U / R
Label3.Caption = ": " + Format$(I, "0.00")
+ "A"
Else
Label3.Caption = " "
+ " ."
End If
Exit Sub
End If
If Option2.Value = True Then
'
I = Val( Text1.Text)
R = Val(Text2.Text)
U= I * R
Label3.Caption = ": " + _
Format$(U, "0.00") + " B"
Exit Sub
End If
If Option3.Value = True Then
'
U = Val(Text1.Text)
I = Val(Text2.Text)
www.WarezOk.ru
I.
20
If I <> 0 Then
R = U / I
Label3.Caption = ": " + _
Format$(R, "0.00") + " "
Else
Label3.Caption = " .
End If
End If
End Sub
'
Private Sub Comrnandl_Click()
If Text1.Text <> "" And Text2.Text <> "" Then
Calculate
Else
Label3.Caption = "
" ."
End If
End Sub
'
Private Sub Optionl_Click()
Labell.Caption = " ():"
Label2.Caption = " ():"
Label3.Caption = ""
End Sub
'
Private Sub Option2_Click()
Labell.Caption = " ():"
Label2.Caption = " ():"
Label3.Caption = ""
End Sub
www.WarezOk.ru
"
I.
21
'
Private Sub Option3_Click()
Labell.Caption = " ():"
Label2.Caption = " ():"
Label3.Caption = ""
End Sub
' /
Private Sub TextlJKeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 48 To 57, 8
' <Backspace>
Case 13
' <Enter>
Text2,SetFocus
Case 44, 46
'
KeyAscii =46
'
If InStr(Text1.Text, ".") 0 Then
KeyAscii =0
End If
Case Else
KeyAscii = 0
'
End Select
End Sub
' /
Private Sub Text2_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 48 To 57, 8
' <Backspace>
Case 13
' <Enter>
Calculate
Case 44, 46
'
KeyAscii = 46
'
If InStr(Text2.Text, ".") <> 0 Then
www.WarezOk.ru
I.
22
KeyAscii =0
End If
Case Else
KeyAscii = 0
End Select
End Sub
'
9. , , . . 1.7.
. 1.7.
' Tag
' Textl, Text2
' 1, 2 3. Tag
' KeyPress.
Private Sub Fomr\_Initialize()
Textl.Tag = 1
' Tag Textl
Text2.Tag = 2
' Tag Text2
Text3.Tag =3
' Tag Text3
End Sub
'
www.WarezOk.ru
I.
23
'
' ,
' .
If rast = 0 Or cena = 0 Or potr = 0 Then
Label4.Caption = " ."
If Len(tl.Text) = 0 Then
Textl.SetFocus
Else
If Len(Text2.Text) = 0 Then
Text2.SetFocus
Else
Text3.SetFocus
End If
End If
Exit Sub
End If
sumn = (rast / 100) * potr * cena
mes = " "
If Checkl.Value = Checked Then
summ = summ * 2
www.WarezOk.ru
I.
mes = mes
End If
24
"
"
www.WarezOk.ru
I.
25
End Sub
'
Private Sub Textl_KeyPress(KeyAscii A* Integer)
Call KeyPress(KeyAscii, Textl)
End Sub
'
Private Sub t2_KeyPress(KeyAscii A* Integer)
Call KeyPress(KeyAscii, Text2)
End Sub
'
Private Sub Text3_KeyPress (KeyAscii A* Integer)
Call KeyPress(KeyAscii, Text3)
End Sub
10. "" .
. 1.8. .
click. click
, .
1.8.
www.WarezOk.ru
I.
'
'
26
1. Click
'
' : 1 "+", 2 - "-",
' 0 - "" ( "=")
Dim f As Integer
' f = 0 , ,
' , .
' f = 1 .
' ""
Private Sub Command0_Click()
If f = 0 Then
'
Text1.Text = ""
f = 1
'
Else
' ,
1
.
If Text1.Text <> "" Then
Text1.Text = Text1.Text + ""
End If
End If
End Sub
' "1"
Private Sub Command1.Click()
If f = 0 Then
'
Textl.Text = "1"
f = 1
'
Else
' ,
' "", f 1,
www.WarezOk.ru
I.
27
' .
' ,
' ( "01"),
' .
If Text1.Text "" Then
Text1.Text = Text1.Text + "1"
Else: Text1.Text = "1"
End If
End If
End Sub
' "2"
Private Sub Command2_Click()
If f = 0 Then
Textl.Text = "2"
f = 1
Else
If Text1.Text <> "0" Then
Text1.Text = Textl.Text + "2"
Else: Text1.Text = "2"
End If
End If
End Sub
' "3"
Private Sub Command3_Click ()
If f = 0 Then
Text1.Text = "3"
f = 1
Else
If Text1.Text <> "0" Then
Text1.Text = Text1.Text +
Else: Text1.Text = "3"
End If
"3"
www.WarezOk.ru
I.
28
End if
End Sub
' "4"
Private Sub Command4_Click()
If f = 0 Then
Text1.Text = "4"
f = 1
Else
If Text1.Text <> "0" Then
Text1.Text = Textl.Text + "4"
Else: Text1.Text = "4"
End If
End If
End Sub
' "5"
Private Sub Command5_Click()
If f = 0 Then
Text1.Text = "5"
f = 1
Else
If Text1.Text <> "0" Then
Text1.Text = Text1.Text + "5"
Else: Text1.Text = "5"
End If
End If
End Sub
' "6"
Private Sub Command6_Click()
If f = 0 Then
Textl.Text = "6"
f=1
www.WarezOk.ru
I.
Else
If Text1.Text <> "" Then
Text1.Text = Text1.Text + "6"
Else: Text1.Text = "6"
End If
End If
End Sub
' "7"
Private Sub Command7_Click()
If f = 0 Then
Text1.Text = "7"
f = 1
Else
If Text1.Text <> "0" Then
Text1.Text = Text1.Text + "7"
Else: Text1.Text = "7"
End If
End If
End Sub
' "8"
Private Sub Command8_Click()
If f = 0 Then
Text1.Text = "8"
f = 1
Else
If Text1.Text <> "0" Then
Text1.Text = Text1.Text + "8"
Else: Text1.Text = "8"
End If
End If
End Sub
www.WarezOk.ru
29
I.
30
' "9"
Private Sub Command9_Click()
If f = 0 Then
Textl.Text = "9"
f = 1
Else
If Text1.Text <> "0" Then
Text1.Text = Text1.Text + "9"
Else: Text1.Text = "9"
End If
End If
End Sub
' "" -
Private Sub CommandC_Click ()
Text1.Text = "0"
accum =0
oper =0
f = 0
'
End Sub
' "+"
Private Sub CommandPlus_Click()
' "+" :
' , ,
'
' .
If f = 0 Then
' ,
'
= 1
'
Else
' ,
'
www.WarezOk.ru
I.
31
DoOper
= 1
f =
End If
End Sub
"-"
Private Sub CommandMinus_Click()
' . Click
' "+"
If f = 0 Then
pper = 2
'
Else
DoOper
= 2
f = 0
End If
End Sub
'
'
'
=
Private Sub CornnandEnter_Click()
' . .
Click'
'
If = 0 Then
=
Else
DoOper
=
f = 0 "
End If
End Sub
www.WarezOk.ru
I.
32
0 Then
'
Sub DoOper()
Dim numb As Single
'
'
'
'
accum
,
r - , ,
.
numb = Val(Textl.Text)
Select Case oper
Case 0: accum = numb
Case 1: accum = accum + numb
Case 2: accum = accum - numb
End Select
Text1.Text = Format$(accum)
End Sub
'
Private Sub Form_Initialize()
oper =0
End Sub
'
www.WarezOk.ru
I.
33
: 1
'
'
'
""
"+",
2 "=")
Dim f As Integer
' f = 0 , ,
' , .
' f = 1 .
' "" - "9"
Sub DigitClick(Command As CommandButton)
Select Case Command.Tag
Case 1 To 9
If f = 0 Then '
Textl.Text
=
Format$(Command.Tag)
f = 1
'
Else
' ,
' "", f
www.WarezOk.ru
"-",
I.
34
' 1,
' .
' , ,
' ( "01") ,
' .
If Textl.Text <> "" Then
Text1.Text = Textl.Text + Format$(Command.Tag)
Else: Textl.Text = Format$(Command.Tag)
End If
End If
Case 0
If f = 0 Then
'
Textl.Text = ""
f = 1 .
'
Else
' ,
1
' .
If Textl.Text <> "0" Then
Textl.Text = Textl.Text + ""
End If
End If
End Select
End Sub
' "+", "-" "="
Sub OperClick(det As Integer)
' "+", "-" "=" :
' , ,
'
1
.
1
det : 1 - "+", 2 - "-", 0 - "="
If f = 0 Then
' ,
www.WarezOk.ru
I.
35
'
Select Case det
'
Case 0: oper = 0
1: oper =1
2: oper = 2
End Select
Else
' ,
'
DoOper
'
Select Case det
'
0: oper =0
1: oper =1
2: oper = 2
End Select
f = 0
'
End If
End Sub
' "0"
Private Sub Command0_Click()
Call DigitClick(Command0)
End Sub
' "1"
Private Sub Commandl_Click()
Call DigitClick(Commandl)
End Sub
' "2"
Private Sub Cornmand2_Click()
Call DigitClick(Command2)
End Sub
www.WarezOk.ru
I.
36
' "3"
Private Sub Command3_Click()
Call DigitClick (Command3)
End Sub
' "4"
Private Sub Command4_Click()
Call DigitClick(Command4)
End Sub
' "5"
Private Sub Command5_Click()
Call DigitClick(Command5)
End Sub
' "6"
Private Sub Command6_Click()
Call DigitClick(Command6)
End Sub
' "7"
Private Sub Conunand7_Click()
Call DigitClick(Command7)
End Sub
' "8"
Private Sub Coinmand8_Click()
Call DigitClick(Command8)
End Sub
' "9"
Private Sub Cornmand9_Click()
Call DigitClick(Command9)
End Sub
www.WarezOk.ru
I.
'
'
www.WarezOk.ru
37
I.
38
'
Sub DoOper()
Dim numb As Single
'
' accum ,
' - , ,
' .
numb = Val(tl.Text)
Select Case oper
Case 0: accum = numb
Case 1: accum = accum + numb
Case 2: accum = accum - numb
End Select
Text1.Text = Formats(accum)
End Sub
'
Private Sub Form_Initialize()
'
Command0.Tag =0
Commandl.Tag =1
Command2.Tag =2
Command3.Tag =3
Command4.Tag =4
Command5.Tag =5
Command6.Tag =6
Command7.Tag =7
Command8.Tag =8
Command9.Tag =9
Tag
www.WarezOk.ru
"" -
"9"
I.
r =
End Sub
39
'
Private Sub Text1_KeyPress(KeyAscii As Integer)
'
KeyAscii =0
End Sub
. 1.9.
'
Sub ShowTime()
Label1.Caption = CStr(Time)
End Sub
'
Private Sub Form_Initialize()
'
Timer1.Interval =1000
' 1
Timer1.Enabled = True
'
Labell.Font.Size =20 '
'
End Sub
' Paint
Private Sub Form_Paint()
www.WarezOk.ru
I.
40
Call ShowTime
End Sub
'
Private Sub Timer1_Timer()
Call ShowTime
'
End Sub
12. " "
. . 1.10.
. 1.10.
'
Sub ShowTime()
Label1.Caption = CStr(Time)
End Sub
'
Private Sub Form_Initialize()
'
Timer1.Interval =1000 '
Timer1.Enabled = True
'
-1
'
Label1.Font.Size =20 '
'
Label2.Font.Size = 10 '
'
Labell .Alignment = 2 '
www.WarezOk.ru
I.
41
Label2.Alignment=2
'
Label2.Caption = CStr(Date)
End Sub
' Paint
Private Sub Form_Paint()
Call ShowTime
'
End Sub
'
Private Sub Timer1_Timer()
Call ShowTime
'
End Sub
. 1.11.
'
Sub ShowTime()
Labe11.Caption = CStr(Time)
End Sub
'
Private Sub Form_Initialize()
Dim stDay, stMonth
www.WarezOk.ru
I.
42
"
' 1, ..
'
1
Timer1.Interval =1000
Timer1.Enabled = True
'
'
'
Label1.Font.Size = 20
Label2.Font.Size =
'
'
'
'
Labell.Alignment = 2
Label2.Alignment = 2
End Sub
'
Paint
ShowTime
'
End Sub
'
ShowTime
-1
'
'
10
'
End Sub
www.WarezOk.ru
I.
43
14. "" . .
. 1.12.
. 1.12.
'
'
' "/"
Private Sub Commandl_Click()
If Timer1.Enabled Then
' ,
Timer 1.Enabled = False
'
Commandl. Caption = ""
Labe13.Visible = False
'
'
'
Label1.Visible = True
Text1.Visible = True
Label2.Visible = True
Text2.Visible = True
'
Text1.Text = Format$(min)
Text2.Text = Format$(sec)
www.WarezOk.ru
I.
44
Else
' ,
min = Val(Text1.Text)
sec = Val(Text2.Text)
If (sec = 0) And (min = 0) Then
'
Label1.Visible = False
Text1.Visible = False
Label2.Visible = False
Text2.Visible = False
Label3.Visible = True
Command1.Caption = ""
Call ShowTime
End If
End Sub
1
'
Private Sub Form_Initialize()
Label3.Visible = False
'
'
Label3.Alignment = 2
'
'
Label3.Font.Size = 20
'
Timer1.Interval =1000
' - 1
Timer1.Enabled = False
'
End Sub
www.WarezOk.ru
I.
45
'
Sub ShowTime()
'
Label3.Caption = Format$(min, "00") + ":" + _
Format$(sec, "00")
End Sub
'
Private Sub Timer1_Timer ()
If sec <> 0 Then
sec = sec - 1
Else
sec =59
min = min - 1
End If
'
Call ShowTime
If
(min =
0)
And
(sec
0)
'
Timerl.Enabled = False
'
Then
www.WarezOk.ru
I.
46
Label1.Visible = True
Text1.Visible = True
Label2.Visible = True
Text2.Visible = True
Text1.Text = "0"
Text2.Text = "0"
End If
End Sub
15.
"".
,
.
. 1.12.
API-
Playsound
'
Private Declare Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszSoundName As String, _
ByVal hModule As Long, ByVal uFlags As Long) As Long
' lpszSoundName - ,
' hModule - ,
' ( ,
' 0),
' uFlags - ,
' :
' SND_ALIAS - &10000 - ,
' SND_ASYNC = &H1 - , . .
' ,
' ,
' SND_FILENAME = &H20000 - ,
' SND_LOOP " &H8 - ,
'
' ,
' SND_NODEFAULT " &H2 - ,
1
'
, Windows,
SND PURGE = &H40 - ,
www.WarezOk.ru
I.
47
SND_ALIAS = &H10000
SND_ASYNC = &H1
SND_FILENAME = &H20000
SND_LOOP = &H8
SND_NODEFAULT = &H2
SND_PURGE = &H40
SND_SYNC = &H0
'
'
' "/"
Private Sub Commandl_Click()
If Timer1.Enabled Then
' ,
Timer1.Enabled = False
'
Command1.Caption = ""
Label3.Visible = False
'
'
'
Label1.Visible = True
t1.Visible = True
Label2.Visible = True
Text2.Visible = True
'
Textl.Text - Format$(min)
Text2.Text = Format$(sec)
www.WarezOk.ru
I.
48
Else
' ,
min = Val(Text1.Text)
sec = Val(Text2.Text)
If
'
'
Label1.Visible = False
Textl.Visible = False
Label2.Visible = False
Text2.Visible = False
Label3.Visible = True
Commandl.Caption = ""
Call ShowTime
End If
End Sub
'
Private Sub Form_Initialize()
Label3.Visible = False
'
'
Label3.Alignment = 2
'
'
Label3.Font.Size = 20
'
Timerl.Interval =1000
' - 1
Timerl.Enabled = False
'
End Sub
www.WarezOk.ru
I.
49
' ,
Sub ShowTime()
'
Label3.Caption = Format$(min, "00") + ":"
Format$(sec, "00")
End Sub
+ _
'
Private Sub Timer1_Timer()
If sec <> 0 Then
sec = sec - 1
Else
sec = 59
min = min - 1
End If
Call
If
ShowTime
'
' :
Call PlaySound(CStr(CurDir) + "\ringer.wav",
_
SND_FILENAME Or SND_ASYNC)
' Call PlaySound("SystemStart", 0, _
SND_ALIAS Or SND_ASYNC) -
0,
' Windows
' (,
' Windows)
Command1.Caption = ""
Label3.Visible = False
'
www.WarezOk.ru
I.
50
'
'
Label1.Visible = True
Text1.Visible = True
Label2.Visible = True
Text2.Visible = True
Text1.Text = "0"
Text2.Text = "0"
End If
End Sub
. 1.13.
Standart,
ToolBox
,
UpDown .
Project
Components
Microsoft
6.0
Buddy Control
UpDown2
- Text2) ,
Text
UpDown Text,
UpDown
( UpDownl
- Textl,
Buddy Property
www.WarezOk.ru
I.
51
'
'
' "/"
Private Sub Command1_Click()
If Timer1.Enabled Then
' ,
Timer1.Enabled = False
'
Commandl.Caption = ""
Label3.Visible = False
'
'
'
Label1.Visible = True
Text1.Visible = True
Label2.Visible = True
Text2.Visible = True
UpDownl.Visible = True
UpDown2.Visible = True
'
Textl.Text = Format$(min)
Text2.Text = Format$(sec)
Else
' ,
min = Val(Textl.Text)
sec = Val(Text2.Text)
If (sec = 0) And (min = 0) Then
Call MsgBox(" .",
www.WarezOk.ru
I.
52
vbOKOnly,
"")
Exit Sub
End If
Timer1.Enabled = True
'
'
Label1.Visible = False
Text1.Visible = False
Label2.Visible = False
Text2.Visible = False
Label3.Visible = True
UpDown1.Visible = False
UpDown2.Visible = False
Conmand1.Caption = ""
Call ShowTime
End If
End Sub
'
Private Sub Form_Initialize()
Label3.Visible = False
'
'
Label3.Alignment = 2
'
'
Label3.Font.Size = 20 '
Timer1.Interval =1000 ' - 1
Timer1.Enabled = False
'
UpDown1. =
60
UpDown2.Max =59
UpDown2.Wrap = True
'
'
'
'
'
""
""
""
www.WarezOk.ru
I.
53
'
'
'
'
'
UpDown1.Wrap = True
End Sub
59,
Up ()
0,
Down () - 59.
""
'
Sub ShowTime()
'
Label3.Caption = Forma1(min, "00") + ":" + _
Format$(sec, "00")
End Sub
'
Private Sub Timer1_Timer ()
If sec <> 0 Then
sec = sec - 1
Else
sec =59
min = min - 1
End If
Call ShowTime
If
'
www.WarezOk.ru
I.
54
'"" - .
Command1.Caption = ""
Labe13.Visible = False
'
'
'
Label1.Visible = True
Text1.Visible = True
Label2.Visible = True
Text2.Visible = True
Textl.Text = "0"
Text2.Text = "0"
UpDownl.Visible = True
UpDown2.Visible = True
End If
End Sub
Private Sub Textl_KeyPress(KeyAscii As Integer)
'
KeyAscii =0
End Sub
Private Sub Text2_KeyPress(KeyAsrii As Integer)
'
KeyAscii =0
End Sub
www.WarezOk.ru
PictureBox.
(, ,
. .) Line Circle.
, , Line Circle
ForeColor, DrawStyle DrawWidth
, .
() , Line circle, Filicolor Filistyle , .
, Print, Font ,
.
Paint.
1.
, .
,
.
. 2.1.
www.WarezOk.ru
I.
56
. 2.1.
'
Private Type Point
X As Integer
Y As Integer
End Type
Const PI
Const R =
Point
= 3.14159265
'
10
'
""
Dim Color
'
Sub StarDraw(xO As Single, yO As Single, R As Integer)
' xO, yO - , R - .
Dim p(l To 11) As Point
'
Dim a As Integer
' ,
'
'
Dim i As Integer
a =
'
'
18
For i = 1 10
www.WarezOk.ru
2.
57
'
/ 2.75 * Cos(a *
/ 2.75 * Sin(a *
* Cos(a * 2 * PI
* Sin(a * 2 * PI
2 * PI / 360))
2 * PI / 360))
/ 360))
/ 360))
'
'
For i = 1 To 10
Line (p(i).X, p(i).Y)-(p(i + 1).X, p(i + 1).Y), Color
Next i
End Sub
Private Sub Form_Load()
Forml.ScaleMode = vbPixels
'
'
End Sub
'
Private Sub Form_MouseDown(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
' Button :
' - Button = 1, - Button = 2
If Button = vbLeftButton Then
'
Color = RGB(255, 0, 0)
Else: Color = RGB(0, 0, 0)
'
End If
Call StarDraw(X,
End Sub
Y,
R)
www.WarezOk.ru
I.
58
2. "". "", .
,
10 . ,
, . 2.2.
. 2.2.
Dim fx,
f As Integer
Dim n As Integer
Dim p As Integer
'
Sub EraseFace(X,
Y As Integer)
'
'
FillStyle =0
'
FillColor = Form1.BackColor
Circle
(X,
Y),
15,
Form1.BackColor
End Sub
'
www.WarezOk.ru
2.
Sub PaintFace(X,
FillStyle = 0
59
Y As Integer)
' -
0)
'
'
FillColor = RGB(0, 0, 0)
Circle(X+5, Y - 5), 1, RGB(0,
Circle(X-5, Y - 5), 1, RGB(0,
0)
0)
'
'
0,
0,
FillStyle = 1
'
'
Circle (X, Y), 10, RGB(0, 0, 0), 3.14, 3.14 * 2
End Sub
' "Ok"
Private Sub Coramandl_Click()
Command1.Visible = False
Label1.Visible = False
n = 0
P = 0
Call PaintFace(fx, fy)
Timer1.Interval = 800
Timer1.Enabled = True
End Sub
'
Private Sub Form_Initialize()
Label1.Caption=" " +
_
". - " +
_
" . - ."
Forml.ScaleMode = 3 '
fx = 100
'
www.WarezOk.ru
I.
fy =
60
100
Randomize
End Sub
'
'
Private Sub Form_MouseDown(Button As Integer, Shift As
Integer, X As Single, Y As Single)
If Button = 1 Then
'
n = n + 1
'
If
(X > fx - 15)
And
(Y > fy - 15) And (Y <
p = p + 1 '
End If
(X <
fy +
If n = 10 Then
'
Timerl.Enabled = False
'
fx + 15)
15) Then
'
MsgBox ": 10. : "
Format$() + ". ", vbOKOnly, "
."
' ,
'
Call EraseFace(fx, fy)
Label1.Visible = True
Command1.Visible = True
End If
And _
+ _
"Ok"
End If
End Sub
www.WarezOk.ru
2.
61
'
Private Sub Timer1_Timer ()
'
Call EraseFace(fx, fy)
'
fx = Int(((Forml.ScaleWidth - 30) * Rnd) +1) +15
' ((Forml.ScaleWidth - 30) * Rnd -
,
' 1 (Forml. Width - 30) , 30 -
fy = Int(((Forml.ScaleHeight - 30) * Rnd) + 1) + 15
Call PaintFace(fx,
End Sub
fy)
3. .
. 2.3.
.2.3.
Const L
Const H
Const x
Const
Private
= 125 '
= 25 '
= 25 '
= 25
Sub Form_Initialize()
' ,
Form1.Height = (Form1.Height - Form1.ScaleHeight) +
www.WarezOk.ru
I.
62
( * 3 + * 2) * Screen.TwipsPerPixelY
Form1.Width = (Form1.Width - Form1.ScaleWidth) + _
(L + x * 2) * Screen.TwipsPerPixelX
'Form1.Height- ,
'Form1.ScaleHeight- ,
' Form1.Width Form1.ScaleWidth.
' ( * 3 + * 2) Screen.TwipsPerPixelY,
'.. Forml.Height , ,
' (L + * 2) Screen.TwipsPerPixelX.
ScaleMode = vbPixels '
'
End Sub
' Paint
Private Sub Forro_Paint ()
Line (x, y)-Step(L, H) , RGB(255, 255, 255),
' (/) -
,
' (L,H) - ,
' RGB (0, 0, 255) - ,
' BF - .
' BF ,
' .
Line
Line
BF
'
Line (x, y)-Step(L,
End Sub
),
RGB(0,
0,
0),
4.
(. 2.4). . 2.5.
www.WarezOk.ru
2.
63
()
. 2.4.
. 2.5.
' , ,
' : , b, d .
' .
Dim p As Integer
'
Dim u As Integer
'
www.WarezOk.ru
I.
64
'
'
Sub a(i As Integer)
If i > 0 Then
Call d(i - 1)
Line -(CurrentX + u, CurrentY)
Call a(i - 1)
Line -(CurrentX, CurrentY + u)
Call a(i - 1)
Line -(CurrentX - u, CurrentY)
Call c(i - 1)
End If
End Sub
'
Sub b(i As Integer)
If i > 0 Then
Call c(i - 1)
Line -(CurrentX - u, CurrentY)
Call b(i - 1)
Line -(CurrentX, CurrentY - u)
Call b(i - 1)
Line -(CurrentX + u, CurrentY)
Call d(i - 1)
End If
End Sub
'
Sub c(i As Integer)
If i > 0 Then
Call b(i - 1)
Line -(CurrentX, CurrentY - u)
Call c(i - 1)
www.WarezOk.ru
2.
65
' (
)
' 2 1 (2^ size =2
For i = 1 ( - 1)
size = size * 2
Next i
size = size - 1
Form1.Height =
1)
(Form1.Height - Form1.ScaleHeight) + _
www.WarezOk.ru
I.
66
(size + 2) * u * Screen.TwipsPerPixelY
Forml.Width = (Forml.Width - Forml.ScaleWidth) + _
(size + 2) * u * Screen.TwipsPerPixelX
Forml.ScaleMode = 3
End Sub
' Paint
Private Sub Form_Paint()
Forml.CurrentX = u
Forml.CurrentY = u
'
Call a(p)
End Sub
5.
. . 2.6.
. 2.6.
Dim x0, y0 As Integer
Dim dx, dy As Integer
Dim h, w As Integer
'
' X
'
www.WarezOk.ru
2.
67
'
Dim x,
Dim lx,
Dim dlx,
As Integer
ly As Single
dly As single
'
'
'
'
()
X Y
()
X Y
'
'
' X
'
Private Sub Form_Initialize()
Form1.BackColor = RGB(255,
255,
255)
h
w
x0 = 30
0 = 15
'
+ h
(30,
15 + h)
dx = 30
dy = 30
dcross = 1
' X :
' dcross = 1 - ,
' dcross - 2 - ,
' dcross = 3 - . .
dlx =0.5
dly = 1
' X
' Y, :
' 1, 2, 3, 4 . .
cross = dcross
www.WarezOk.ru
I.
68
' X
'
, X
= + dx
ix = dix
;
While (x < xO + w)
Line (x, yO + 3)-(, yO - 3)
'
cross = cross - 1
If cross = 0 Then
'
Form1.CurrentX = x - 8
Form1.CurrentY = yO + 5
Print Formats(lx, "0.0")
cross = dcross
End If
Form1.DrawStyle = 2
' :
'
Line (x, yO - 5)-(, yO - h)
'
Forml.DrawStyle = 0
' :
'
lx = lx + dlx
= + dx
Wend
1
www.WarezOk.ru
2.
69
' ,
= - dy
1 * dly
While ( > - h)
(xO
5,
Forml.DrawStyle
= - dy
y)-(xO
=
+ w,
'
ly = ly + dly
Wend
End Sub
6. (
2sin(x)ex/5) .
. 2.7.
. 2.7.
'
Private Sub Form_Initialize()
www.WarezOk.ru
I.
70
Form1.BackColor = RGB(255,
End Sub
255,
255)
' ,
Function f(x As Single) Single
f = 2 * Sin(x) * Exp(x / 5)
End Function
'
Sub DrawGraph()
' :
Dim x1 As Single, x2 As Single
' :
Dim y1 Single, y2 As Single
Dim Single
'
Dim Single
'
Dim dx s Single
'
Dim l, b s Integer '
'
Dim w, h s Integer '
'
' X Y:
Dim mx s Single, my s Single
' :
Dim 0 Integer, yO s Integer
'
Forml.SealeMode = 3
l = 10
' -
'
b = Form1.ScaleHeight - 20
' Y-
'
h = Form1.ScaleHeight - 40
'
w = Form1.ScaleWidth - 20
'
www.WarezOk.ru
2.
x1 = 0
2 = 25
dx = 0.01
'
'
71
'
'
' [x1, 2]
yl = f(xl)
'
2 = f(2)
'
X = Xl
While ( <= 2)
= f()
If < yl Then yl =
' ,
' . .
If > 2 Then y2 =
' :
' ,
' . .
= + dx
Wend
'
my = h / Abs(2 - y1)
' Y
' X
'
'
0 = 1
0 = b - Abs(Round(y1 * my))
Line (1, b)-(l, b - h)
Line (x0, y0)-(x0 + w, y0)
Form1.CurrentX =1+5
www.WarezOk.ru
I.
72
Form1.CurrentY = b - h
Print Format$(y2, "##0.000")
Form1.CurrentX =1+5
Form1.CurrentY = b - 12
Print Format$(yl, "##0.000")
'
X = X1
While (x <= x2)
= f (x)
PSet (xO + Round(x
RGB(200, 0, 0)
x = x + dx
Wend
End Sub
* mx),
yO
- Round(y * my)),_
' Paint
Private Sub Form_Paint()
Call DrawGraph
End Sub
'
Private Sub Form_Resize()
Forml.Cls
'
Call DrawGraph
'
End Sub
7. (. 2.8)
.
Dim n(1 To 5)
Dim ncolor(2
As Integer
To 5)
Dim ntext(2 To 5)
'
' ,
'
' ,
'
'
www.WarezOk.ru
2.
73
. 2.8.
'
Sub gistr(Area As Object)
'
'
'
n(5)
(4)
n(3)
n(2)
n(1)
'
= Val(Text5.Text)
= Val(Text4.Text)
= Va1(t3.Text)
= Val(Text2.Text)
= n(5) + n(4) + n(3) + n(2)
max
For
=
i
n(2)
= 3
If max <
Next i
To
n(i)
Step
Then max =
n(i)
www.WarezOk.ru
I.
74
'
If (n(l) = 0) Or (max = 0)
'
Area.ScaleMode = vbPixels
' Area
h = Area.ScaleHeight
w = Area.ScaleWidth
'
Area.Cls
'
Area.Font.Size = 8
'
For i
5 2
Area
Step -1
Area.Line (5 * (6 - i) + 35 *
Step(35, -h *
(n(i) / max) * 0.8), ncolor(i), BF
'
(5
Area.Line (5 * (6 - i) + 35 * (5
Step(35, -h *
(n(i) / max) * 0.8), RGB(0, 0, 0),
'
Area.CurrentX = 5 * (6
i)
+ 35
i),
- i),
(5
h)-
i)
-
15
'
ntext(5) = Left(Label5.Caption,
Len(Label5.Caption)-
1)
ntext(4)
ntext(3)
ntext(2)
Len(Label4.Caption)Len(Label3.Caption)Len(Label2.Caption)-
1)
1)
1)
Next
h)-
0.8)
= Left(Label4.Caption,
= Left(Label3.Caption,
= Left(Label2.Caption,
www.WarezOk.ru
2.
75
For i = 5 To 2 Step -1
' ()
Area.Line(5 * 6 + 35 * .4, h * 0.2 + 20 * (5 - i))
8t*p(35, 15), ncolor(i), BF
Area.Line(5 * + 35 * 4, h * 0.2 + 20 * (5 i))
Stp(35, 15), RGB(0, 0, 0),
'
Area.CurrentX =5*7+35*5
Area.CurrentY = h * 0.2 + 20 *
Area.Print Format(ntext(i))
Next i
(5 - i)
End Sub
'
Private Sub Form_Load()
' Picture1
Picturel.BackColor = RGB(255, 255, 255)
'
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
'
ncolor(5) = RGB(240, 0, 50)
ncolor(4) = RGB(0, 220, 0)
ncolor(3) = RGB(0, 50, 200)
ncolor(2) = RGB(245, 220, 0)
End Sub
'
www.WarezOk.ru
I.
76
End Select
End Sub
'
www.WarezOk.ru
2.
Case
48
Case
13
77
To
57,
8
'
'
<Backspace>
<Enter>
Command1.SetFocus
Case Else
KeyAscii
'
End Select
End Sub
'
Private Sub Commandl_Click()
Call gistr(Picturel)
End Sub
8.
, .
. 2.9.
. 2.9.
'
Const R = 70
www.WarezOk.ru
I.
78
'
'
Private Sub Form_Initialize()
Forml.Height = (Form1.Height - Form1.ScaleHeight) + _
(R + 10) * 2 * Screen.TwipsPerPixelY
Forml.Width (Forml.Width - Forml.ScaleWidth) + _
(R + 10) * 2 * Screen.TwipsPerPixelX
'Forml.Height- ,
'Forml.ScaleHeight- ,
' Forml.Width Forml.ScaleWidth.
'(R + 10) * 2 Screen.TwipsPerPixelY,
'.. Forml.Height , ,
' (R + 10)*2 Screen. TwipsPerPixelX.
= R + 10
= R + 10
'
ahr = 90 amin = 90
asec = 90 -
Hour(Time) * 30 - (Minute(Time)
- Minute(Time) * 6
Second(Time) * 6
Timer1.Interval = 1000
Timer1.Enabled = True
Form1.ScaleMode = 3
End Sub
/12)
'
'
- 1
' (0,0)
Sub Vector(x0 As Integer, y0 As Integer, _
a As Integer, 1 As Integer)
' 0, 0 -
www.WarezOk.ru
2.
79
' - X
' 1 -
Dim , As Integer
'
=.Round(0 + 1 * Cos(a * GRAD))
= Round(y0 - 1 * Sin(a * GRAD))
Line (x0, y0)-(x, y)
End Sub
'
Sub DrawClockO
' 6 ,
' - 30.
'
Form1.DrawWidth = 3
'
Form1.ForeColor = Form1.BackColor
'
Call Vector(x0, y0, ahr, R - 20)
'
Call Vector(x0, y0, amin, R - 15)
'
Call Vector(x0, y0, asec, R - 7)
'
ahr = SO - Hour(Time) * 30 - (Minute(Time)/12)
amin = 90 - Minute(Time) * 6
asec = 90 - Second(Time) * 6
'
'
Form1.DrawWidth = 3
Form1.ForeColor = RGB(0, 0, 0)
Call Vector(x0, yO, ahr, R - 20)
www.WarezOk.ru
I.
80
'
Form1.DrawWidth = 2
Call Vector(x0, y0, amin, R - 15)
'
Form1.DrawWidth = 1
Form1.ForeColor = RGB(200, 0, 0)
Call Vector(x0, y0, asec, R - 7)
End Sub
'
Private Sub Form_Paint()
Dim x As Integer
'
Dim As Integer
'
Dim a As Integer
' X
' (x0, 0) - (,
Form1.DrawWidth =1
Form1.ForeColor = RGB(0,
a =
0
'
0,
0)
' 3- ,
'
While (a < 360)
= xO + Round(R
= xO - Round(R
*
*
Cos(a
Sin(a
*
*
*
*
2
2
PI
PI
If
'
www.WarezOk.ru
/
/
360))
360))
2.
81
Call DrawClock
End Sub
'
Private Sub Timer1_Timer ()
Call DrawClock
End Sub
9.
, .
. 2.10.
. 2.10.
Const R = 60
Const GRAD = 0.0174532
'
'
'
Const PI = 3.14159265
Dim x0 As Integer, y0 As Integer
Dim ahr As Integer
Dim amin As Integer
Dim asec As Integer
www.WarezOk.ru
I.
82
'
Private Sub Form_Initialize()
Form1.Height = (Form1.Height - Forml.ScaleHeight)
(R + 30) * 2 * Screen.TwipsPerPixelY
Form1.Width = (Forml.Width - Forml.ScaleWidth) + _
(R + 30) * 2 * Screen.TwipsPerPixelX
xO
yO
= R +
= R +
30
30
'
ahr = 90 - Hour(Time) * 30 amin = 90 - Minute(Time) * 6
asec = 90 - Second(Time) * 6
Timer1.Interval =1000
Timer1.Enabled = True
Form1.ScaleMode =3
End Sub
'
(Minute(Time)
'
'
Sub Vector(xO As Integer, y0 As Integer,
a As Integer, 1 As Integer)
'
'
+ _
x0, y0 -
a - X
' 1 -
Dim , As Integer
'
= Round(x0 + 1 * Cos(
= Round(y0 - 1 * Sin(a
Line (xO, y0)-(x, y)
End Sub
*
*
GRAD))
GRAD))
'
Sub DrawClock()
' 6 ,
www.WarezOk.ru
12)
(0,0)
2.
83
' -30.
'
Form1.DrawWidth = 3
'
Form1.ForeColor = Form1.BackColor
'
Call Vector(x0, y0, ahr, R - 20)
'
Call Vector(x0, y0, amin, R - 15)
'
Call Vector(x0, y0, asec, R - 7)
'
ahr = 90 - Hour(Time) * 30 - (Minute(Time)
amin = 90 - Minute(Time) * 6
asec = 90 - Second(Time) * 6
'
'
Form1.DrawWidth = 3
Form1.ForeColor = RGB(0, 0, 0)
Call Vector(xO, yO, ahr, R - 20)
'
Form1.DrawWidth ~ 2
Call Vector(x0, yO, amin, R - 15)
'
Form1.DrawWidth = 1
Form1.ForeColor = RGB(200, 0, 0)
Call Vector(xO, yO, asec, R - 7)
End Sub
'
Private Sub Form_Paint()
Dim x As Integer
'
Dim s Integer
'
www.WarezOk.ru
/12)
* 6
I.
84
Dim a As Integer
'
Dim h As Integer
' X
(, ) - (, )
'
Form1. DrawWidth =1
Form1.ForeColor = RGB(0,
a =
0
'
h =
0,
0)
' 3-
' 0 -
'
While (a < 360)
= 0 + Round(R *
= 0 - Round(R *
Cos(a
Sin(a
*
*
2
2
*
*
PI
PI
/
/
360))
360))
If
a = a +
Wend
'
Call DrawClock
www.WarezOk.ru
- 7
2.
85
End Sub
'
Private Sub Timer1_Timer ()
Call DrawClock
End Sub
10. ,
. . 2.11. (. . 2.12) .
. 2.11.
. 2.12.
www.WarezOk.ru
I.
86
'
Private Sub Form_Initialize()
'
Picture1.BorderStyle =
Picture1.Picture = LoadPicture(CurDir + "\back.bmp")
Picture3.Borderstyle = 0
Picture3.Picture = LoadPicture(CurDir + "\plane. bmp")
Picture3.Visible = False
' Picture2 - PictureBox,
' .
' Picture3 Picture1.
Picture2.BorderStyle =0
Picture2.Height = Picture3.Height
Picture2.Width = Picture3.Width
Picture2.Left - Picturel.Left - Picture2.Width
Randomize
'
www.WarezOk.ru
2.
87
Else
Picture2.Left = Picture2.Left+25
End If
'
' (Picture1)
' Picture2
Picture2.PaintPicture Picturel.Picture, _
-Picture2.Left, -Picture2.Top
' Picture3 Picture2
For dx = 1 To Picture3.Width Step Screen.TwipsPerPixelX
For dy = 1 To Picture3.Height Step
Screen.TwipsPerPixe1Y
'
npoint = Picture3.Point(dx, dy)
' (RGB (255, 255, 255)),
' Picture3 Picture2,
' . . .
If npoint <> RGB(255, 255, 255) Then
Picture2.PSet (dx, dy), npoint
End If
Next dy
Next dx
Picture2.Visible = True
End Sub
11.
, .
. 2.13.
. 2.14.
"mult.trap"
' ,
'
Const Nframe = 12
'
' ( )
Dim fw As Integer
'
Dim fH As Integer
Const f_name =
www.WarezOk.ru
I.
88
. 2.13.
. 2.14. ( )
Dim currentFrame As
'
Integer
'
= False
Picture2.AutoSize = True
'
Picture2 ,
' Picturel
Picture2.Picture = LoadPicture(CurDir +
fW = Round(Picture2.Width
fH = Picture2.Height
"\"
Nframe)
Picturel.Height = fH
Picturel.Width = fW
currentFrame =
Timer1.Interval
1
=
100
Timer1.Enabled = True
www.WarezOk.ru
f_name)
2.
89
End Sub
'
Private Sub Timer1_Timer ()
'
If currentFrame > Nframe Then currentFrame = 1
'
Picture1.PaintPicture Picture2.Picture, _
0, 0,
, , fW * (currentFrame -1), 0, fW, fH
' PaintPicture Picture2.Picture
' Picture1.Picture:
'0,0- ,
' fW * (currentFrame - 1) , 0 -
,
' ,
' fW, fH -
currentFrame
End Sub
currentFrame
12. ,
(
).
. 2.15.
. 2.15.
Dim fW As Integer, fH As Integer
'
www.WarezOk.ru
I.
90
' Ok
Private Sub Comnandl_Click()
Unload Form1
End Sub
'
Private Sub Form_Initialize()
Piture2.Visible = False
Picture2.AutoSize = True
Picture2.Picture = LoadPicture(CurDir + "\banner.bmp")
fW = Picture2.Width
fH = Picture2.Height
Forml.Width = Forml.Width + Picture2.Width Picture1.Width
Picturel.Width = Picture2.Width
x =
=
Timer1.Interval =50
Timer1.Enabled = True
End Sub
'
Private Sub Timer1_Timer ()
= + 10
' Picturel Picture2
Picture1.PaintPicture Picture2.Picture,
-x, -y
'
' (Picture2),
'
www.WarezOk.ru
2.
91
13. "" ( ).
. 2.16.
. 2.16.
'
' Ok
Private Sub Coinmandl_Click()
Unload Form1
End Sub
'
Private Sub Fom_Initialize()
Picture2.Visible = False
Picture2.AutoSize = True
Picture2.Picture = LoadPicture(CurDir + "\banner.bmp")
fW = Picture2.Width
fH = Picture2.Height
Form1.Height = Form1.Height + Picture2.Height - _
www.WarezOk.ru
I.
92
Picture1.Height
Coramand1.Top = Command1.Top + Picture2.Height
Picture1.Height
Picture1.Height = Picture2.Height
x =
=
- _
Timer1.Interval =50
Timerl.Enabled = True
End Sub
'
Private Sub Timerl_Timer ()
x = x + 40
' Picturel Picture2
Picturel.PaintPicture Picture2.Picture,
-x, -y
'
' (Picture2),
'
If + Picturel.ScaleWidth >= Picture2.ScaleWidth Then
Picturel.PaintPicture Picture2.Picture, _
-x + Picture2.ScaleWidth, -y
End If
14.
, .
. 2.17.
www.WarezOk.ru
2.
93
. 2.17.
Dim
Dim
Dim
Dim
Dim
dh As Integer
dw As Integer
direct As String
fname As String
ftype As String
'
first ,
' direct: 1
Dim resize As Single
Imagel
first As
Integer)
-,
0
'
- .
'
Image1.Visible = False
www.WarezOk.ru
I.
94
first = 0 Then
' , ,
'
If Dir(direct, vbDirectory) = "" Then
Call MsgBox(" .",
vbOKOnly, " ")
Cdmmandl.Enabled = False
Exit Sub
Else
' 1-
fname = Dir(direct + ftype)
End If
End If
If
fname <>
""
Then
'
ommand1.Enabled = True
Image1.Picture = LoadPicture(direct +
fname)
'
If Image1.Height > dh Or _
Image1.Width > dw Then
Imagel.Stretch = True
resize =
Image1.Width /
Image1.Height
'
www.WarezOk.ru
2.
95
Image1.Width = dw
'
Image1.Height = dw / resize
Else
'
Image1.Width = dh * resize
Image1.Height = dh
End If
End If
' ,
' fname
If fname = "" Then Command1.Enabled = False
' ,
'
fname = Dir
Else
If
first = 0 Then
Call MsgBox("
" .", _
vbOKOnly, " ")
End If
End If
Image1.Visible = True
End Sub
'
Private Sub Command1_Click()
'
Call show_pic(direct, 1)
End Sub
'
Private Sub Form_Initialize()
www.WarezOk.ru
"
+ _
I.
96
ftype = "*.bmp"
dw = Image1.Width
dh = Image1.Height
Command1.Enabled = False
' pictures
Textl.Text = CurDir + "\pictures\"
direct = Textl.Text
' , ,
' Windows:
' Textl.Text = Environ("windir")
' direct = Textl.Text + "\"
Call
show_pic(direct,
0)
End Sub
' - bmp
Private Sub Optionl_Click()
ftype = "*.bmp"
Call show_pic(direct, 0)
End Sub
' - jpg
Private Sub Option2_Click()
ftype = "*.jpg"
Call show_pic(direct, 0)
End Sub
' - gif
Private Sub Qption3_Click()
ftype = "*.gif"
Call showjpic(direct, 0)
End Sub
www.WarezOk.ru
2.
97
'
13
Integer)
Then
= Textl.Text
"\"
show_pic(direct,
0)
End If
End Sub
15. , ,
, Windows.
. 2.18.
. 2.18.
'
Private Sub Form_Load()
'
'
-
Windows bmp;
' Environ("windir")
- ,
Windows,
"\"
+ _
"\*.bmp"))
' :
www.WarezOk.ru
I.
'
98
Image1.Picture=LoadPicture(CurDir+ "\background.bmp")
Image1.Visible = False
End Sub
' Paint
Private Sub Form_Paint()
Dim x As Integer
'
Dim As Integer
'
Image1
www.WarezOk.ru
3.
99
Microsoft
Multimedia Control (MMControl).
PictureBox.
API-.
1. " Windows"
, Windows\Media.
.3.1.
. 3.1. Windows
www.WarezOk.ru
I.
100
'
'
'
(MMControl)
(File1)
+ _
'
Private Sub Form_Initialize()
Label1.Caption =
'
"
" Play."
- Windows,
'
"\Media\"
Filel.Pattern =
'
'
- ,
Windows.
' Media
'
+ _
Windows:
Filel.Path = Environ("windir")
'
"
"*.wav"
(Filel)
wav
MMCOntroll
Play Stop
MMControl1.PauseVisible = False
MMControl1.PrevVisible = False
MMControl1.NextVisible = False
MMControl1.RecordVisible = False
www.WarezOk.ru
3.
101
MMControl1.EjectVisible
= False
MMControl1.BackVisible = False
MMControl1.StepVisible
= False
End Sub
' MMControl1
Integer)
MMControl1.Command =
"PREV"
MMControl1.Command =
"STOP"
End Sub
'
MMControll.Command =
"CLOSE"
End Sub
2.
, -.
.
. 3.2.
. 3.2. CD-player
'
'
www.WarezOk.ru
I.
102
'
'
Sub cd_inf()
Timer1.Enabled = False
MMControl1.Command = "CLOSE"
MMControl1.Command = "OPEN"
MMControl1.TimeFormat =0
Label1.Caption =
Label2.Caption =
Label6.Caption =
"00"
"00:00"
"00:00"
Command1.Caption =
"Play"
If MMControl1.Tracks = 0 Then
Command1.Enabled = False '
www.WarezOk.ru
3.
103
+ _
End If
End If
End Sub
' ,
' ": : "
Private Function toHMS(time As Long) As String
Dim H As Integer
'
Dim M As Integer
'
Dim S As Integer
'
H =
M =
S =
+ Format(S,
www.WarezOk.ru
I.
104
lse
Timer1.Enabled = False
Command1.Caption = "Play"
MMControl1.Command = "STOP"
MMControl1.Track = 1
Label1.Caption = Format(MMControl1.Track, "0#")
Label6.Caption = toHMS(MMControl1.TrackLength)
Label2.Caption = "00:00"
Command3.Enabled = False
Command2.Enabled = True
End If
End Sub
' Next ( )
Private Sub Command2_Click()
MMControl1.Command = "NEXT"
If MMControl1.Track = 2 Then Command3.Enabled = True
If MMControl1.Track = MMControl1.Tracks Then _
Command2.Enabled = False
Label6.Caption = toHMS(MMControl1.TrackLength)
Label1.Caption = Format(MMControl1.Track, "0#")
End Sub
' Previous ( )
Private Sub Command3_Click()
MMControl1.Command = "PREV"
If MMControl1.Track = 1 Then Command3.Enabled = False
If MMControl1.Track = MMControl1.Tracks - 1 Then _
Command2.Enabled = True
Label6.Caption = toHMS(MMControl1.TrackLength)
Label1.Caption = Format(MMControl1.Track, "0#")
www.WarezOk.ru
3.
105
End Sub
Private Sub Form_Initialize ()
Label7.Alignment = 2 '
'
Timer1.Interval = 100
r
' - CDAudio
MMControll.DeviceType = "CDAudio"
MMControll.Visible = False
Call cd_info
cd_id = 1
End Sub
'
'
Private Sub Form_Unload(Cancel As Integer)
MMControl1.Command = "STOP"
MMControl1.Command = "CLOSE"
End Sub
' MMControll
Private Sub MMControll_StatusUpdate()
' ,
'
If MMControl1.Mode =525 And cd_id = 0 Then
Call cd_info
'
cd_id = 1
End If
'
If MMControl1.Mode =530 Then
www.WarezOk.ru
I.
106
Call cd_info
cd_id = 0
End If
End Sub
'
Private Sub Timer1_Timer()
' ,
If MMControl1.Position >= MMControl1.Length Then
MMControl1.Command = "STOP"
MMControl1.Track =1
Label1.Caption = Format(MMControll.Track, "0#")
Label6.Caption = toHMS(MMControll.TrackLength)
Label2.Caption = "00:00"
Command3.Enabled = False
Command2.Enabled = True
Timer1.Enabled = False
Exit Sub
End If
'
If MMControl1.Position - MMControl1.TrackPosition < _
MMControl1.TrackLength Then
Label2.Caption = toHMS(MMControl1.Position - _
MMControll.TrackPosition)
' MMControll.Position - ,
' MMControll.TrackPosition - ;
' ;
Else
' ,
MMControl1.Track = MMControl1.Track +1
Label1.Caption = Format(MMControl1.Track, "0#")
www.WarezOk.ru
3.
107
Label6.Caption = toHMS(MMControl1.TrackLength)
Label2.Caption = toHMS(MMControl1.Position - _
MMControl1.TrackPosition)
If MMControl1.Track = 2 Then Command3.Enabled True
If MMControl1.Track = MMControl1.Tracks Then
Command2.Enabled = False
End If
End Sub
3.
"-"
.
. slider. ,
, .
FileListBox DirListBox.
Audio-player, ,
. 3.3.
. 3.3. Audio-player
www.WarezOk.ru
I.
108
,
Forml
'
Private Declare Function waveOutSetVolume Lib "winmm.dll" _
(ByVal uDevicelD As Long, ByVal dwVolume As Long) As Long
'
Private Declare Function waveOutGetVolume Lib "winmm.dll" _
(ByVal uDevicelD As Long, ByVal dwVolume As Long) As Long
' uDevicelD - ID() ,
' .
' dwVolume: -
' , - :
' 0000 - , FFFF - .
' : &HFFFFFFFF - 100% ,
' &0 - 0% ,
' &HFFFF0000 - 100% , - 0%.
' &HFFFF - 100% , 0% - .
Dim
Dim
Dim
Dim
( )
'
www.WarezOk.ru
3.
109
"00")
'
Private Sub Form_Initialize()
File1.Pattern = "*.mp3"
' mp- ,
' , *.wav, :
' File1.Pattern = "*.mp3; *.wav"
File1.Path = CurDir +
"\mp3\"
MMControl1.Visible = False
MMControl1.TimeFormat =0
Label1.Caption = "00:00:00"
Timer1.Interval = 100
Timer1.Enabled = False
If File1.ListCount
Command2.Enabled
Command3.Enabled
Command4.Enabled
End If
'
= 0 Then
= False
= False
= False
- 50%
www.WarezOk.ru
I.
110
Slider1.Min =0
Slider1.Max = 100
SIider1.Value =50
' - 100%
Slider2.Min = -100
Slider2.Max = 100
rVolume = 100
lVolume = 100
'
100))
"&H"
& rLevel
&
lLevel)
' Open ( )
Private Sub Command1_Click()
' Form2,
'
Form2.Show
Forml.Enabled = False
End Sub
Form1
www.WarezOk.ru
3.
111
"OPEN"
"PLAY"
Timer1.Enabled = True
Command2.Caption = "Stop"
Else
MMControl1.Command = "STOP"
MMControl1.Command = "CLOSE"
Timer1.Enabled = False
Command2.Caption = "Play"
Label1.Caption = "00:00:00"
End If
End Sub
' Next ( )
Private Sub Command3_Click()
If Filel.Listlndex < Filel.ListCount -
www.WarezOk.ru
1 Then
I.
112
'
If MMControl1.Command = "PLAY" Then
MMControl1.Command = "CLOSE"
File1.ListIndex = File1.Listlndex + 1
MMControl1.FileName = Filel.Path + "\"
File1.FileName
MMControl1.Command =
MMControl1.Command =
+ _
"OPEN"
"PLAY"
'
Else
File1.Listlndex = Filel.Listlndex + 1
MMControl1.FileName = Filel.Path + "\"
Filel.FileName
End If
End If
End Sub
+ _
' Prev ( )
Private Sub Command4_Click()
If File1.ListIndex > 0 Then
'
If MMControl1.Command = "PLAY" Then
MMControl1.Command = "CLOSE"
File1.ListIndex = File1.Listlndex - 1
MMControl1.FileName = File1.Path + "\"
File1.FileName
MMControl1.Command =
MMControl1.Command =
'
"OPEN"
"PLAY"
www.WarezOk.ru
+ _
3.
113
Else
File1.ListIndex = Filel.ListIndex - 1
MMControl1.FileName = Filel.Path + "\"
File1.FileName
End If
End If
End Sub
+ _
'
Private Sub File1_Click()
'
If Command2.Caption = "Stop" Then
MMControl1.Command = "CLOSE"
MMControl1.FileName = Filel.Path +"\"+Filel.FileName
MMControl1.Command = "OPEN"
MMControl1.Command = "PLAY"
End If
End Sub
'
Private Sub Form_Unload(Cancel As Integer)
MMControl1.Command * "STOP"
MMControl1.Command = "CLOSE"
End Sub
'
Private Sub Slider1_Scroll()
'
rLeve1 = Hex(65535 * (rVolume / 100) * _
(Slider1.Value / 100))
lLeve1 = Hex(65535 * (lVolume / 100) * _
(Slider1.Value / 100))
If Len(lLeve1)
<
4 Then
www.WarezOk.ru
I.
114
Do
lLeve1 = "0" + lLeve1
Loop Until Len(lLeve1) =4
End If
Call waveOutSetVolume(0,
End
"&H"
& rLeve1
&
lLeve1)
Sub
'
Private Sub Slider2_Scroll()
'
If Slider2.Value = 0 Then
lVolume = 100
rVolume =100
End If
'
www.WarezOk.ru
3.
115
End If
Call waveOutSetVolume(0,
End Sub
"&H"
'
Private Sub Timer1_Timer ()
If MMControl1.Position < MMControl1.Length Then
Label1.Caption = toHMS(MMControll.Position)
Else
If File1.ListIndex < Filel.ListCount - 1 Then
MMControl1.Command = "CLOSE"
File1.Listlndex = Filel.Listlndex + 1
MMControl1.FileName = Filel.Path + "\"
File1.FileName
MMControl1.Command =
MMControl1.Command =
Else
MMControl1.Command =
+ _
"OPEN"
"PLAY"
"CLOSE"
If Check1.Value = 1 Then
File1.Listlndex = 0
MMControl1.FileName = Filel.Path +
Filel.FileName
MMControl1.Command = "OPEN"
MMControl1.Command = "PLAY"
Else
Timer1.Enabled = False
Command2.Caption =
"Play"
www.WarezOk.ru
"\"
I.
116
Label1.Caption =
Filel.ListIndex =
End If
End If
End If
End Sub
'
'
"00:00:00"
,
Form2
' Ok
Private Sub Commandl_Click()
' Filel
' Form1
Form1.File1.Path = Dirl.Path
'
If Form1.MMControl1.Command = "PLAY" Then
Form1.MMControl1.Command = "STOP"
Form1.MMControl1.Command = "CLOSE"
Form1.Timer1.Enabled = False
Forml.Command2.Caption = "Play"
Form1.Label1.Caption = "00:00:00"
If Form1.File1.ListCount <> 0 Then
Form1.File1.Listlndex = 0
Form1.MMControl1.FileName = Form1.File1.Path + _
"\" +
Form1.File1.FileName
Form1.MMControl1.Command ="OPEN"
www.WarezOk.ru
3.
117
Form1.MMControl1.Command =
"PLAY"
Form1.Timer1.Enabled = True
Form1.Command2.Caption =
End If
End If
"Stop"
Unload Form2
End Sub
' Cance1
Private Sub Command2_Click()
Unload Form2
End Sub
'
Private Sub Drive1_Change()
' (
' , ).
'
' drive_error ( ).
On Error GoTo drive_error
Dir1.Path = Drive1.Drive + "\"
'
drive_error:
' ,
'
Drive1.Drive = Dir1.Path
End Sub
'
www.WarezOk.ru
I.
118
4.
As
Integer)
, -
(ID3v1 Tag) : , , .
.
"ID3v1 Tag ditor" ID3v1- . . 3.4
. 3.5.
www.WarezOk.ru
3.
119
String
Title As String
30
Artist As String
30
Album As
30
Year As
String
String
Comment As String
Track As
4
*
30
Integer
Genre As Byte
End Type
Dim fPath As String
Dim gPath As String
'
ID3v1
Tag -
www.WarezOk.ru
I.
120
www.WarezOk.ru
3.
'
'
'
'
'
'
'
'
'
'
'
'
'
1
'
'
'
'
'
'
1
If
121
, .
,
,
. - ,
.
ID3v2 Tag ( ID3 Tag)
:
ID3v2 Tag:
(3 ) ID3,
ID3v2 Tag. ID3v2 Tag
ID3vl Tag: Composer,
Orig.Artists, Copyright, URL, Encoded by.
,
ID3vl Tag: 16 ID3v2 Tag
(), Tag' - 256.
ID3v2 Tag
, . .
ID3vl Tag.
fTag.Tag_Id = "TAG" Then
Title 30 (
' ), Get ifNumber, ,
' 30
' ,
' Tag_Id (Tag_Id 3 )
Get ttfNumber, , fTag.Title
1
'
Get ttfNumber, , fTag.Artist
Get #fNumber, , fTag.Album
Get ttfNumber, , fTag.Year
www.WarezOk.ru
Title
I.
Get #fNumber,
Get #fNumber,
,
,
122
fTag.Comment
fTag.Genre
'
'
'
30 ,
'
30-
'
'
' 30
'
0 .
'
2- .
'
ID3vl- 1 255.
'
'
WinAmp
0 ,
' .
'
255,
'
256.
' :
If InStr(fTag.Comment, Chr(O))
InStrifTag.Comment,
'
fTag.Comment
0.
'
Right(Right(fTag.Comment,
'
fTag.Comment -
'
1))
Chr(O))
1)
1
'
Asc(...)
'
- 0 255.
'
Command.2. Tag ,
'
ID3vl
Then _
fTag.Track = Asc(Right(fTag.Comment,
1
Tag
Command2.Tag =1
Else
www.WarezOk.ru
3.
123
Call MsgBox( _
"ID3vl Tag , .",
_
vbOKOnly + vblnformation, "ID3vl Tag ")
' Command2 ,
' ID3vl Tag
Command2. Tag = 0
Text1.Text
Text2.Text
Text3.Text
Text4.Text
Text5.Text
Text6.Text
=
=
=
=
=
=
""
""
""
""
""
""
Exit Sub
End If
'
Close #fNumber
' :
Textl.Text = fTag.Title
Text2.Text = fTag.Artist
Text3.Text = fTag.Album
Text4.Text = fTag.Year
Text5.Text = fTag.Comment
If fTag.Track <> 0 Then
Text6.Text = fTag.Track
Else: Text6.Text = ""
End If
If fTag.Genre <= 147 Then
www.WarezOk.ru
I.
124
Combo1.ListIndex = fTag.Genre
Else: Combo1.ListIndex = 0
End If
End Sub
' ID3 Tag mp-
Sub Save_Id3v1tag(fPath As String)
Dim fNumber Aa Integer
Dim fTag As id3tag
fNumber = FreeFile
'
Open fPath For Binary As
#fNumber
fTag.Tag_Id = "TAG"
fTag.Title = Text1.Text & _
String(30 - Len(Text1.Text), Chr(O))
fTag.Artist = Text2.Text & _
String(30 - Len(Text2.Text), Chr(O))
fTag.Album = Text3.Text & _
String(30 - Len(Text3.Text), Chr(0))
fTag.Year = Text4.Text & _
String(4 - Len(Text4.Text), Chr(0))
fTag.Track = Val(Text6.Text) Mod 256
If
www.WarezOk.ru
Chr(0)
3.
End
125
If
If Combo1.ListIndex = -1 Then
fTag,Genre = 0
Else
fTag.Genre = Combo1.ListIndex
End If
' ID3v1 Tag,
' FileLen (fPath) -127,
'
,
(
)
If Command2.Tag <> 0 Then
Put #fNumber, FileLen(fPath) - 127, fTag.Tag_Id
Else: Put #fNumber, FileLen(fPath), fTag.Tag_Id
End If
Put
Put
Put
Put
Put
Put
#fNumber, ,
#fNumber,
#fNumber,
#fNumber, ,
#fNumber, ,
#fNumber, ,
fTag.Title
,
fTag.Artist
,
fTag.Album
fTag.Year
fTag.Comment
fTag.Genre
'
Close #fNumber
End Sub
' Open
Private Sub Commandl_Click()
CommonDialog1.DialogTitle = " mp3-"
CommonDialog1.Filter = "mp3- (*.mp3)|*.mp3"
CommonDialog1.FilterIndex =1
CommonDialog1.Flags = cdlOFNNoChangeDir
' Windows
www.WarezOk.ru
I.
126
CommonDialog1. ShowOpen
If CommonDialog1.FileName <> ""
Command2.Enabled = True
Command2. Tag = 0
fPath = CommonDialog1.FileName
Call Id3v1tag(fPath)
End If
End Sub
Then
'
Save
Private Sub Command2_Click()
Call Save_Id3v1tag(fPath)
Call
Id3v1tag(fPath)
End Sub
'
Exit
'
Private Sub Form_Initialize()
Dim fNumber As Integer
Dim curString As String
fNumber = FreeFile
Form1.Icon = LoadPicture(CurDir +
"Veditor.ico")
Text1.Text=""
Text2.Text=""
Text3.Text=""
Text4.Text=""
Text5.Text=""
www.WarezOk.ru
3.
Text6.Text =
127
""
Text1.MaxLength=30
Text2.MaxLength=30
Text3.MaxLength=30
Text4.MaxLength=4
Text5.MaxLength=30
Text6.MaxLength=3
Command2.Enabled = False
Command2.Tag =0
gPath = CurDir +
"\id3v1__genre_list.txt"
' Combo1 ,
Open gPath For Input As #fNumber
'
Do While Not EOF (fNumber)
Line Input #fNumber, curString
'
' Combol
Combol.Addltern Right(curString, Len(curString)-4), _
Val(Left(curString, 3))
Loop
'
Close #fNumber
' Combo1
' ,
' 2 - Dropdown list Style.
End Sub
' Year
Private Sub Text4_KeyPress(KeyAscii As Integer)
www.WarezOk.ru
I.
128
End Select
End Sub
'
'
' Track
Private Sub Text6_Change()
Select Case KeyAscii
Case 48 To 57, 8
' 0 - 9
Backspace
Case Else
KeyAscii = 0
'
End Select
End Sub
www.WarezOk.ru
;
OnError.
1. " "
Text. . 4.1.
. 4.1.
' , ,
' ,
www.WarezOk.ru
I.
'
'
'
'
'
'
'
130
,
MultiLine Text2 True.
, , , . .
MultiLine
. ScrollBars
2 - Vertical, Text2
.
'
""
www.WarezOk.ru
Or _
4.
131
FileName = ""
Call MsgBox(" .",
vbOKOnly, " ")
Exit Sub
End If
'
'
'
'
'
'
'
'
'
'
'
'
'
Input -
t2.Text:
Line Input #FileNumber, current_string ,
FileNumber - ,
current_string - ,
;
Input
:
Input(Number, #FileNumber)
Number - ,
FileNumber - ;
http://www.WarezOk.ru
'
'
If Check1.Value = 1 Then
Text2.Locked = True
'
www.WarezOk.ru
I.
132
'
Command2.Enabled = False
Else
'
Text2.Locked = False
Command2.Enabled = True
End
If
End Sub
'
""
""
If Dir(FileName)
""
And Check1.Value =
#1,
#1
'
Text2.Text
Close #1
End If
End Sub
'
Private Sub Form_Initialize()
Command2.Enabled = False
Text2.Locked = True
End Sub
'
0 Then
'
<Enter>
www.WarezOk.ru
4.
133
2. .
. 4.2.
. 4.2.
'
1
'
1
True.
2
Text2
ScrollBars
Vertical,
' .
'
MultiLine
Text2
Locked
' True.
Dim FileName As String
'
' Dir1
www.WarezOk.ru
I.
134
'
Text1.Text =
""
'
'
End Sub
'
Private Sub Drive1_Change()
' (
' , ).
'
' drive_error ( ).
On Error GoTo drive_error
Dirl.Path = Drivel.Drive + "\"
Filel.Path = Drivel.Drive
Text1.Text = ""
'
drive_error:
' ,
'
Drive1.Drive = Dirl.Path
End Sub
'
Private Sub File1_Click()
' Click File1 ,
1
- File1.
' , Click ,
' . . , File1. FileName
' "" .
If Len(File1.Path) <> 3 Then
www.WarezOk.ru
4.
135
' File1.Path = 3,
' File1.Path - ( " :\ " ).
filepath = File1.Path + "\" + Filel.FileName
Else:
End If
Textl.Text =
'
'
""
'
Dim fileMask As String
Dim n As Integer
'
'
,
'
www.WarezOk.ru
I.
136
. 4.3.
'
'
find
Function find(dir_path As
String)
'
Dirl.Path = dir_path
Filel.Path = dirjpath
'
If Filel.ListCount <>
'
Filel.ListCount
'
Filel.Path
If Mid(fileMask,
'
0 Then
-
1,
1)
"*"
Then
File1,
'
www.WarezOk.ru
4.
137
' List1
File1.Pattern = fileMask
For i = 0 To
n = n + 1
(Filel.ListCount
1)
Step 1
' List1
' ( )
If Len(File1.Path). <> 3 Then
Listl.Addltem File1.Path + "\" + File1.List(i)
Else: List1.Addltem File1.Path + File1.List(i)
End If
' Listl.Addltem File1.Path + File1.List(i) ' File1.Path + File1.List (i)
' List1
Next i
Else
'
For i = 0 (File1.ListCount - 1) Step 1
If File1.List(i) = fileMask Then
n = n + 1
' List1
If Len(File1.Path) <> 3 Then
List1.Addltem File1.Path + "\" + _
File1.List(i)
Else: List1.Addltem File1.Path + File1.List(i)
End If
End If
Next i
End If
www.WarezOk.ru
I.
138
End If
' Dir1.Path
' :
1
Dir1.List (i), i - ;
' - Dir1.ListCount,
' 0 Dir1.ListCount-1
'
If Dir1.ListCount 0 Then
back_path = Dir1.Path
'
For j = 0 (Dir1.ListCount - 1) Step
Dir1.Path = back_path
Call find(Dir1.List(j))
Next j
End If
'
Label2.Caption =
" :
"
+ Format(n)
End Function
' ""
Private Sub Coramand1_Click()
If Text1.Text <> "" Then
Dir1.Visible = False
Command1. Enabled = False
'
n = 0
Label2.Caption = " : " + Format(n)
List1.Clear
'
www.WarezOk.ru
4.
139
fileMask = Text1.Text
'
If Len(Dir1.Path) 3 Then
'
find(cDir)
Dir1.Path = cDir
Dir1.Visible = True
Command1.Enabled = True
If n = 0 Then
Call MsgBox(", "
" .", , " ")
End If
Else
Call MsgBox(" .",
" ")
End If
End Sub
'
Private Sub Drive1_Change()
' (
' , ).
'
' drive_error ( ).
On Error GoTo drive_error
Dir1.Path = Drive1.Drive + "\"
'
www.WarezOk.ru
I.
140
drive_error:
' ,
'
Drive1.Drive = Dir1.Path
End Sub
'
Private Sub Form_Initialize()
Drive1.Drive = "c"
File1.Visible = False
End Sub
'
'
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then Coramand1.SetFocus
End Sub
www.WarezOk.ru
5
-,
, .
1. "15". . 15 , 1 15. 4x4, ,
.
(. 5.1). , ,
, (. 5.2). " 15"
.
. 5.3. ,
, .
. 5.1.
. 5.2.
www.WarezOk.ru
I.
142
. 5.3. 15
Const =
Const
4,
CH =
W =
50,
4
CW =
50
1 )
Dim stp(1 To W,
'
As Integer
'
1 )
Dim pole(1 To W,
Dim ex As Integer,
As Integer
ey As Integer
'
'
'
Sub newGame()
For i
For j
'
1 To H Step 1
stp(i,
j)
pole(i,
Next
Next
stp(W,
'
1 To W Step 1
=
j)
H)
=
=
(i
stp(i,
1)
* W + j
j)
www.WarezOk.ru
5.
Call mixer
Call showPole
End Sub
'
Sub showPole()
Dim i As Integer,
Dim X As Integer,
j As Integer
Y As Integer ' x,y -
'
'
Form1.Cls
' :
For i = 1 (W - 1)
Line (i * CW, 0)-(i * CW, CH * H)
Next i
' :
For i = 1 To (H - 1)
Line (0, i * CH)-(CW * W, i * CH)
Next i
' ( )
For i = 1
Y = (i - 1) * CH + 18
For j = 1 To W
X = (j - 1) * CW + 18
Select Case pole(i, j)
Case 0:
Case 1 To 9:
CurrentX = X
CurrentY = Y
Print " " + Format(pole(i, j))
Case 10 To 15:
CurrentX = X
CurrentY = Y
www.WarezOk.ru
143
I.
144
(W
If pole(row, col)
Finish = False
Exit Function
End If
1)
<> i Then
'
If col < W Then
col = col +1
Else
col = 1
row = row + 1
End If
Next i
End Function
'
www.WarezOk.ru
5.
145
Sub mixer ()
Dim xl As Integer,
Dim x2 As
yl As Integer
Integer,
'
y2 As Integer
'
'
'
' ,
Dim d As Integer
xl
yl
'
'
= W
=
i = 1 T W * * 10 Step 1
Do
2
2
=
=
d =
xl
yl
Int((Rnd * W)
+1)
'
'
Select Case d
Case
1:
x2
= x2+1
Case 2:
x2
Case 3:
y2 = y2+1
= x2- 1
Case 4:
y2
= y2-1
End Select
Loop Until
(x2
(y2
pole(yl,
pole(y2,
xl)
x2)
>=
>=
1)
1)
And
And
= pole(y2,
= 0
(x2
(y2
<= W)
<= H)
x2)
xl = x2
yl
Next
= y2
i
www.WarezOk.ru
And_
I.
146
'
ex = xl
= yl
End Sub
' "" ,
' , , .
Sub fMove(cx As Integer, cy As Integer)
' ex, - ,
'
If Not ((Abs(cx - ex) = 1) And ( - = 0)
_
(Abs(cy - ) = 1) And (ex - ex = 0))
Then Exit
Sub
' :
pole(ey, ex) = pole(, )
pole(, ) =0
=
=
(, )
(,
Or
'
Call showPole
If Finish = True Then
y_n = MsgBox(" !" + Chr(13) + _
" ?", vbYesNo, " 15")
If y_n = vbYes Then Call newGame '
If y_n = vbNo Then Unload Forml '
'
End If
End Sub
www.WarezOk.ru
5.
147
'
Private Sub Form_Initialize ()
Form1.Width = (Form1.Width - Form1.ScaleWidth) + _
(CW * W) * Screen.TwipsPerPixelX
Form1.Height = (Form1.Height - Form1.ScaleHeight) +
_
(CH * H) * Screen.TwipsPerPixelY
Form1.Font.Size =10
Form1.SealeMode = 3
Randomize
Call newGame
End Sub
'
Private Sub Form_MouseDown(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
' X, Y -
Dim ex As Integer,
cy As Integer
'
'
= Int(X / CW) + 1
= Int(Y / CH) + 1
Call fMove(cx,
End Sub
' Paint
Private Sub Form_Paint()
Call showPole
End Sub
2. Puzzle "15". , .
(
). . 5.4.
www.WarezOk.ru
I.
148
. 5.4. Puzzle ( )
Const
Dim CH As
4,
W =
Integer,
Dim stp(l To W,
'
CW As
1 To H)
As
Dim ex As
'
1 To H)
Integer,
ey As
As
Integer
'
Integer '
'
To W Step
For
To H Step
stp(i, j)
pole(i, j) =
Next
Next
4x4
Sub newGame()
For
'
Integer '
'
Dim pole(l To W,
Integer
(i-1)* W + j
stp(i, j)
www.WarezOk.ru
5.
stp(W,
H)
149
'
Call mixer
Call
showPole
End Sub
'
Sub showPole()
Dim i As Integer,
Dim X As
Integer,
As Integer
Y As
Integer
'
'
For i
Y =
( )
=
(i
For j
' x,
1)
1 W
=
X =
(j
1)
CW
j)
Case 0:
'
Line
(X,
Y)-Step(CW,
Forml.BackColor,
Line
(X,
Y)-Step(CW,
CH),
BF
CH),
RGB(0,
0,
0),
Case Else:
Dim t
'
t = pole(i,
'
j) / W
'
If t <> Int (pole(i, j) / W) Then
Form1.PaintPicture Picture1.Picture,
www.WarezOk.ru
I.
150
X,
Y,
,
, _
CW * (pole(i, j) - _
W * Int(pole(i, j) / W) - 1),
CH * (Int(pole(i, j) / H)), _
CW, CH
Else
'
Form1.PaintPicture Picturel.Picture, _
X, Y, , , _
CW * (pole(i, j) - _
W * Int (pole(i, j) / W) + 3), _
CH * (Int (pole(i, j) / H) - 1), _
CW, CH
End If
Line
End Select
Next j
Next i
'
(X,
Y)-Step(CW, CH),
RGB(0,
0,
0),
End Sub
'
Sub mixer ()
Dim x1 As Integer, y1 As Integer '
Dim x2 As Integer, y2 As Integer ' ,
'
'
Dim d As Integer
' ,
'
'
xl = W
yl =
www.WarezOk.ru
5.
For i = 1 To W * H
Do
x2=x1
y2=y1
d = Int((Rnd * W)
Select Case
Case
1:
Case
2:
Case
3:
Case
4:
End Select
d
x2
x2
y2
y2
=
=
=
=
151
10
1) ' /
'
x2
x2
y2
y2
Step
+
+
-
1
1
1
1
x1)
x2)
= pole(y2,
= 0
And _
x2)
x1 = x2
y1 = y2
Next i
'
ex = x1
ey = y1
End Sub
' "" ,
' ,
Sub fMove(cx As Integer, cy As Integer)
' ex, - ,
www.WarezOk.ru
I.
152
'
I
If Not ((Abs(cx - ex) = 1) And ( - ey =
(Abs(cy - ey) = 1) And (ex - ex = 0))
Exit Sub
'
pole(ey, ex) = pole(, )
pole(, ) =0
=
=
(,
(,
0) Or _
Then
'
Call showPole
If Finish = True Then
y_n = MsgBox(" !"
" ?", vbYesNo,
If y_n = vbYes Then Call newGame '
If y_n = vbNo Then Unload Forml '
'
End If
+ Chr(13) + _
" 15")
End Sub
' ,
Function Finish() As Boolean
Dim row As Integer, col As Integer
'
row=1
col=1
Finish = True
'
For i = 1 (W * - 1)
If pole(row, col) <> i Then
www.WarezOk.ru
5.
153
Finish = False
Exit Function
End If
'
If col < W Then
col = col + 1
Else
col = 1
row = row + 1
End If
Next i
End Function
'
Private Sub Form_Initialize()
'
Picture1.Visible = False
Picture1.AutoSize = True
Picture1.BorderStyle =0
Picture1.Picture = LoadPicture(CurDir +
"\picture.jpg")
'
CH = Picture1.Height / H
CW = Picture1.Width / w
'
Form1.Width = (Form1.Width - Form1.ScaleWidth) + _
Picture1.Width
Form1.Height = (Form1.Height - Form1.ScaleHeight) + _
Picture1.Height
Randomize
www.WarezOk.ru
I.
154
Call newGame
End Sub
'
Private Sub Form_MouseDown(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
' X, Y -
Dim ex As Integer,
cy As Integer
'
'
= Int(X / CW) + 1
= Int(Y / ) + 1
Call fMove(cx,
End Sub
cy)
' Paint
Private Sub Form_Paint()
Call showPole
End Sub
3. " " . .
,
. ,
, . "". "" , .
, .
.
, "".
. . ,
, ,
. ,
() .
www.WarezOk.ru
5.
. 5.5.
. 5.6.
. 5.7.
www.WarezOk.ru
155
I.
156
(. 5.5). (
) . ,
. . 5.6, . 5.7.
'
'
'
'
'
'
'
-
,
Menu Editor.
:
" "( : Captioon - ,
Name - new_game) ;
"?" ( : Captioon - ?, Name
about).
Const MAX_SIZE =
Const _ = 8
Const MAX_W =8
32
' .
' - 8x8
'
Private Type col_row
col As Integer
row As Integer
End Type
Dim Pole(1 To
' Pole(i,j)
' Pole(i,j)
' Pole(i,j)
'
' Pole (i,j)
col_row
Dim n As Integer
Dim As Integer
'
'
www.WarezOk.ru
5.
'
'
' -
Dim W As Integer
Dim H As Integer
' N
' 2
Dim WK As Integer '
Dim HK As Integer '
'
Private Sub Form_Initialize()
'
Form1.ScaleMode = vbPixels
Picture1.ScaleMode = vbPixels
' Picture1,
'
' PaintPicture
Picture1.BorderStyle =
Picture1.Visible = False
Picture1.AutoSize = True
Picture1.Picture = LoadPicture(CurDir +
"\pictures4x4.bmp")
'
W = 4
H = 4
'
( )
www.WarezOk.ru
157
I.
=
WK =
158
Picture1.Height
Picture1.Width /
Int(H * W /
2)
'
Forml. Width = (W* (WK+5) -5 + 1- Form1.ScaleWidth)
*
Screen.TwipsPerPixelX + Form1.Width
Forml.Height = (H* (HK+5) -5+1- Form1.ScaleHeight)
* Screen.TwipsPerPixelY + Form1.Height
'
Randomize
'
Call NewGame
Timer1.Enabled = False
Timer1.Interval = 300
End Sub
'
Private Sub Form_MouseDown(Button As Integer, _
Shift As integer, X As Single, Y As Single)
Dim col_ As Integer
Dim row_ As Integer
'
'
www.WarezOk.ru
5.
159
If = 0 Then
= 1
open1.col
= col_
open1.row = row_
'
Pole(open1.col, open1.row) = _
Pole(open1.col, open1.row) +
'
Call Kletka(open1.col,
100
open1.row)
Exit Sub
End If
'
If =
1 Then
open2.col = col_
open2 . row = row_
'
' ,
If
(open1.col
= open2.col)
(open1.row = open2.row)
Exit
And _
Then
Sub
Else
= 2
'
Pole(open2.col, open2.row) = _
Pole(open2.col, open2.row) +100
'
Call Kletka(open2.col,
open2.row)
www.WarezOk.ru
I.
160
' ,
If Pole(open1.col, openl.row) = _
Pole(open2.col, open2.row) Then
'
n = n + 1
Timer1.Enabled = True
'
' Timer
'
End If
End If
Exit
End If
Sub
' 2 :
,
' ,
If = 2 Then
'
Pole(open1.col, open1.row) = _
Pole(open1.col, open1.row) - 100
Pole(open2.col, open2.row) = _
Pole(open2.col, open2.row) - 100
Call Kletka(open1.col,
Call Kletka(open2.col,
open1.row)
open2.row)
' open1
open1.col = col_
open1.row = row_
www.WarezOk.ru
5.
'
= 1
161
'
Pole(open1.col, open1.row) = _
Pole(open1.col, open1.row) + 100
Call Kletka(open1.col,
End If
open1.row)
End Sub
'
Sub Kletka (col As Integer, row As Integer)
Dim X As Integer, Y As Integer
'
' ()
'
'
X
Y
= (col - 1) * (WK + 5)
= (row - 1) * ( + 5)
BF
www.WarezOk.ru
I.
162
'
Form1.PaintPicture Picture1.Picture, _
X, Y, , , WK*(Pole(col, row) - 100 - 1), 0, WK, HK
'
Line (X, Y)-Step(WK,
End If
HK),
RGB(0,
0,
0),
If
End Sub
'
Sub ShowPole()
Dim row As Integer, col As Integer
For row = 1 To H
For col = 1 To W
Call Kletka(col, row)
Next col
Next row
End Sub
'
Sub NewGame()
Dim As Integer
' .
Dim r As Integer
'
Dim buf(1 To MAX_SIZE) As Integer
' buf(i) , i
www.WarezOk.ru
5.
163
' Pole
= Int(H * W / 2)
' buf(i)
For i = 1
buf(i) =
Next i
n =
=
' Pole 1 ,
'
For i = 1
For j = 1 W
DO
r = Int((k * Rnd) +1)
'
' 1
Loop Until buf(r) < 2
Pole(i, j) = r
'
buf(r) = buf(r) + 1
Next j
Next i
'
Call ShowPole
End Sub
'
www.WarezOk.ru
I.
164
'
"?"
( )
2004",
vbOKOnly,
" ")
End Sub
'
Paint
'
Call Kletka(open2.col,
Call Kletka(open1.col,
open2.row)
open1.row)
'
Timer1.Enabled = False
' ()
If n = Int(W * / 2) Then _
Call MsgBox("Game Over!",
vbOKOnly,
"
End Sub
www.WarezOk.ru
")
5.
165
4. "" . . ,
. . ,
, , .
,
. , ,
, ( ) (. 5.8). , , ,
.
, ,
. , , ,
( )
, (
, ,
).
; ;
, ; ,
, (. 5.9) picture1
, ,
. . 5.10.
Const MR = 10 '
Const = 10 '
Const NM = 10 '
Const W = 40 '
Const H = 40 '
'
Dim Pole(0 MR + 1, 0 + 1) As integer
' :
' 0...8 - ,
' 9 - ,
1
100..109 - ,
' 200..209 -
www.WarezOk.ru
I.
166
. 5.8.
. 5.9.
. 5.10.
www.WarezOk.ru
5.
167
'
Dim nFlag As
'
Integer
'
'
'
0 - ,
- ,
col As Integer
'
' )
-3.
' _
'
For row =
For col
MR +
Pole(row,
col)
1
+
-3
'
Next col
Next row
Call newGame
'
Form1.Width = (Form1.Width - Form1.ScaleWidth)
(MC
Form1.Height =
* W)
(Form1.Height
(MR * H)
- Form1.ScaleHeight)
Screen.TwipsPerPixelY
'
Form1.ScaleMode = vbPixels
'
+ _
Screen.TwipsPerPixelX
Form1.Icon = LoadPicture(CurDir +
"\saper.ico")
Picture1.BorderStyle =0
www.WarezOk.ru
+ _
I.
168
Picture1.Visible = False
Picture1.AutoSize = True
Picture1.ScaleMode = vbPixels
' Picturel
Picturel.Picture = LoadPicture(CurDir + "\images.bmp")
' 4 ,
' : , , ,
' ,
End Sub
'
Sub Kletka(row As Integer, col As Integer, status As
Integer)
Dim X As Integer, Y As Integer
'
'
'
X = (col - 1) * W
Y = (row - 1) *
'
If status = 0 Then
'
Line
(X,
Line (X,
Exit Sub
End If
Y)-Step(W,
H),
Y)-Step(W,
Form1.BackColor,
H),
RGB(0,
0,
BF
0),
'
If Pole(row, col) < 100 Then
'
Line (X, Y)-Step(W, H), Form1.BackColor, BF
Line (X, Y)-Step(W, H), RGB(0, 0, 0),
' (status = 2)
' ,
www.WarezOk.ru
5.
If (status = 2)
Call Mina(X, Y)
Exit Sub
End If
And
'
Line (X, Y)-Step(W,
Line (X, Y)-Step(W,
169
(Pole(row,
H),
H),
col)
= 9)
Then _
BF
' ,
If (Pole(row, col) = 100) Then Exit Sub
'
If (Pole(row, col) >= 200)
Y)
' ,
If (Pole(row, col)>=101) And (Pole(row, col)<=108) Then
Form1.Font.Size = 14
Form1.ForeColor = RGB(0, 0, 200)
Form1.CurrentX = X + 3
Form1.CurrentY = Y + 3
'
Print Str(Int(Pole(row, col) - 100))
Exit Sub
End If
'
If (Pole(row, col) = 109)
Call MinaBoom(X, Y)
End If
Then
'
If (Pole(row, col) = 209) And
(status = 2)
www.WarezOk.ru
Then
I.
170
Call Flag_Mina(X,
End If
End Sub
Y)
'
Sub ShowPole(status As Integer)
Dim row As Integer, col As Integer
For row = 1 To MR
For col = 1 To MC
Call Kletka(row, col,
Next col
Next row
End Sub
status)
'
' ,
Sub n_open(row As Integer, col As Integer)
If Pole(row, col) = 0 Then
Pole(row, col) = 100
Call Kletka(row, col, 1)
'
Call n_open(row; col - 1)
Call n_open(row - 1, col)
Call n_open(row, col + 1)
Call n_open(row + 1, col)
'
Call n_open(row - 1, col - 1)
Call n_open(row - 1, col +1)
Call n_open(row + 1, col - 1)
Call n_open(row + 1, col +1)
Else
If (Pole(row, col) < 100) And (Pole(row, col)
<> -3) Then
Pole(row, col) = Pole(row, col) + 100
www.WarezOk.ru
5.
Call Kletka(row,
End If
End If
End Sub
col,
171
1)
'
Sub newGame ()
Dim row As Integer
'
Dim col As Integer
Dim n As Integer
Dim As Integer
'
'
'
For row = 1 MR
For col = 1 To MC
Pole(row, col) = 0
Next col
Next row
'
Randomize
'
n = 0
'
DO
row = Int((MR * Rnd) + 1)
col = Int((MC * Rnd) +1)
If (Pole(row, col) <> 9) Then
Pole(row, col) = 9
n = n + 1
End If
Loop Until (n = NM)
'
www.WarezOk.ru
I.
172
'
For row = 1 MR
For col = 1 To MC
If (Pole(row,
col)
<> 9)
Then
=
If Pole(row - 1, col - 1) = 9 Then = + 1
If Pole(row - 1, col) = 9 Then = + 1
If Pole(row - 1, col + 1) = 9 Then = + 1
If Pole(row, col - 1) = 9 Then = + 1
If Pole(row, col + 1) = 9 Then = + 1
If Pole(row + 1, col - 1) = 9 Then = + 1
If Pole(row + 1, col) = 9 Then = + 1
If Pole(row + 1, col + 1) = 9 Then = + 1
Pole(row, col) =
End If
Next col
Next row
status = 0
nMin =0
nFlag = 0
End Sub
'
'
'
'
Sub Flag(X As Integer, Y As Integer)
' Picturel
' PaintPicture
Forml.PaintPicture Picturel.Picture, _
X, Y,
,
, 0, 0, W, H
'
Line (X, Y)- Step (W,
End Sub
H),
RGB(0,
0,
www.WarezOk.ru
0),
5.
173
'
Sub Mina(X As Integer, Y As Integer)
Picture!
PaintPicture
Forml.PaintPicture Picturel.Picture, _
X, Y, ,
, W, 0, W, H
'
' ,
Line (X, Y)-Step (W,
End Sub
H),
RGB(0,
0,
0),
'
Sub Flag_Mina(X As Integer, Y As Integer)
' Picturel
' PaintPicture
Forml.PaintPicture Picturel.Picture, __
X, Y,
, , 2 * W, 0, W, H
'
Line (X, Y)-Step (W,
End Sub
H),
RGB(0,
0,
0),
' ,
Sub MinaBoom(X As Integer, Y As Integer)
' ,
' Picturel PaintPicture
Forml.PaintPicture Picturel.Picture, _
X, Y, ,
, 3 * W, 0, W, H
'
Line (X, Y)-Step (W,
End Sub
H),
RGB(0,
0,
'
www.WarezOk.ru
0),
I.
174
col As Integer
If status
If status
= 0 Then status
'
'
row = Int(Y / ) + 1
col = Int(X / W) + 1
'
If Button = vbLeftButton Then
If Pole(row, col) = 9 Then
' ,
Pole(row, col) = Pole(row, col) + 100
status = 2
'
Call ShowPole(status)
'
Else
'
If Pole(row, col) < 9 Then Call n_open(row,
End If
End If
col)
'
If Button = vbRightButton Then
' ,
www.WarezOk.ru
5.
Call Kletka(row,
'
175
col,
status)
Else
' , ,
' ,
If Pole(row, col) >= 100 Then Exit Sub
nFlag = nFlag +1
Pole(row, col) = Pole(row,
Call Kletka(row,
col,
If Pole(row, col)
riMin = nMin +1
209 Then
'
If (nMin = NM) And (nFlag = NM) Then
status = 2
'
Call ShowPole(status)
'
End If
End If
End If
End If
End Sub
' Paint
Private Sub FormPaint()
'
Call ShowPole(status)
End Sub
www.WarezOk.ru
I.
176
5. "". ,
Ok, . .
.
. 5.11.
'
Private Declare Function PlaySound Lib "winram.dll"_
Alias "PlaySoundA" (ByVal lpszSoundName As String,_
ByVal hModule As Long, ByVal uFlags As Long) As Long
' lpszSoundName - ,
www.WarezOk.ru
5.
177
. 5.11.
' hModule - ,
' ( ,
' 0),
'
uFlags
' :
'
SND_ALIAS
&H10000
' ,
'
SND_FILENAME =
&H20000
- ,
www.WarezOk.ru
I.
Const
Const
Const
Const
178
SND_LOOP = &H8
SND_NODEFAULT = &H2
SND_HJRGE = &H40
SND_SYNC = &H0
www.WarezOk.ru
5.
179
www.WarezOk.ru
0,
I.
180
Label3.Caption = Format(UpDownl.Value,
+ _Format(UpDown2.Value,
"0#")
End Sub
' :
Private Sub UpDown2_Change()
Label3.Caption = Format(UpDownl.Value,
+ _Format(UpDown2.Value,
"0#")
End Sub
"0#")
"0#")
":"
":"
6. "". Ok, ,
(. 5.12).
. .
. 5.13.
. 5.12.
[]
. 5.13.
www.WarezOk.ru
5.
181
'
' ,
' :
' ,
'
PopupExit PopupRestore,
' PopupSysTray,
PopupExit
'
PopupRestore PopupSysTray.
'
Visible
PopupSysTray False.
' Caption
' :
'
'
Private Declare Function Shell_NotifyIcon Lib
Alias
"Shell_NotifyIconA"
- ,
'
"shell32"
_
pnid As NOTIFYICONDATA)
,
( ,
As Boolean
' ),
' lpData
- ,
'
' .
'
Shell_NotifyIcon
String
64
End Type
www.WarezOk.ru
I.
'
182
Const NIM_ADD =
Shell_NotifyIcon
'
'
Const NIM_MODIFY = 1
Const NIM_DELETE = 2
'
'
' :
MouseDown
Const WM_LBUTTONUP =
' :
MouseUp
&202
Const WM_LBUTTONDBLCLK
&H203 '
DblClick
'
Const WM_RBUTTONUP =
'
MouseUp
DblClick
'
&H205
MouseDown
NOTIFYICONDATA
Const NIF_MESSAGE
Const NIF_ICON =2
Const NIF_TIP
Const WM_MOUSEMOVE
'
&H200
"PlaySoundA"
"winmm.dll"
_
_
As Long
- ,
'
lpszSoundName
'
hModule - ,
'
'
'
uFlags
0),
- ,
Const
SND_ALIAS
&H10000
Const
SND_ASYNC
&H1
Const
SND_FILENAME
Const
SND LOOP =
&H20000
&H8
www.WarezOk.ru
5.
Const
Const
Const
183
SND_NODEFAULT = &H2
SND_PURGE = &H40
SND_SYNC = &H0
' ,
'
Dim aSysIcon As NOTIFYICONDATA
'
Dim alarmTime
' Ok
Private Sub Command1_Click()
'
alarmTime = Format(UpDownl.Value, "0#") + ":"
Format(UpDown2.Value, "0#")
+ _
' aSysIcon
aSysIcon.szTip = ": " & alarmTime &
vbNullChar
Shell_NotifyIcon NIM_MODIFY, aSysIcon
'
Form1.Hide
'
Shell_NotifyIcon NIM_ADD, aSysIcon
' ""
Form1.PopupRestore.Enabled = True
End Sub
'
Private Sub Form_Initialize()
Label1.Font.Size =14
Label2.Font.Size =14
Label3.Font.Size = 14
Label1.Alignment = 2 '
www.WarezOk.ru
I.
184
'
UpDown1.Min =0
UpDown1.Max = 23
UpDown2.Min = 0
UpDown2.Max =59
UpDownl.Wrap True
'
' UpDown1
'
UpDown2.Wrap = True
' UpDown2
Timer1.Enabled = True
Timer1.Interval = 1000
'
'
Label1.Caption = Format(Time,
"hh:mm")
Form1.ScaleMode = vbPixels
'
Form1.Icon = LoadPicture(CurDir +
"\alarm.ico")
'
With aSysIcon
.cbSize = Len(aSysIcon)
.hwnd = Forml.hwnd
.uID = 0&
.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
.uCallbackMessage = WM_MOUSEMOVE
.hlcon = Forml.Icon
.szTip = ": " & alarmTime & vbNullChar
End With
End Sub
www.WarezOk.ru
5.
185
'
Private Sub Timer1_Timer ()
If Form1.Visible = True Then
Label1.Caption = Format(Time, "hh:mm")
Else
'
If Format(Time, "hh:mm") = alarmTime Then
'
Call PlaySound(CStr(CurDir) + "\ringer.wav",
_
SND_FILENAME Or SNDJVSYNC)
0,
'
Form1.Show
' ""
Form1.PopupRestore.Enabled = False
End If
End If
End Sub
' :
Private Sub UpDown1_Change()
Label2.Caption = Format(UpDownl.Value,
End Sub
"0#")
' :
Private Sub UpDown2_Change()
Label3.Caption = Format(UpDown2.Value,
End Sub
'
Private Sub Form_Resize()
' /
"0#")
www.WarezOk.ru
I.
186
'
'
' WindowState :
' vbNormal - (),
' vbMinimized - (
' ),
' vbMaximized-
'
If Form1.WindowState = vbMinimized Then
alarmTime = Format(UpDown1.Value, "0#") + ":" + _
Format(UpDown2.Value, "0#")
' aSysIcon
aSysIcon.szTip=": "& alarmTime & vbNullChar
Shell_NotifyIcon NIM_MODIFY, aSysIcon
'
Form1.Hide
'
Shell_NotifyIcon NIM_ADD, aSysIcon
' ""
Forml.PopupRestore.Enabled = True
End If
End Sub
'
Private Sub Form_MouseMove(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
'
Select Case X
www.WarezOk.ru
5.
' : X = 513
Case WM_LBUTTONDOWN
'
Form1.Windowstate = vbNormal
Form1.Show
' ""
Form1.PopupRestore.Enabled = False
' : X -516
Case WM_RBUTTONDOWN
'
Form1.PopupMenu Forml.PopupSysTray
End Select
End Sub
'
Private Sub FormJJnload(Cancel As Integer)
'
ShellJNfotifylcon NIM_DELETE, aSysIcon
End Sub
' ""
Private Sub PopupExit_Click()
Shell_NotifyIcon NIM_DELETE, aSysIcon
Unload Me
End Sub
' ""
Private Sub PopupRestore_Click()
Form1.Windowstate = vbNormal
Form1.Show
www.WarezOk.ru
187
I.
188
' ""
Forml.PopupRestore.Enabled = False
End Sub
7.
"" . ,
(. 5.14).
. 5.14.
. (
(
), , ). .
- !
6
- .
5
- .
4
- !
3
:
" "
www.WarezOk.ru
5.
" "
""
1
" "?
,
1
?
1
"" :
,
1
,
"-", ?
( )
1
:
www.WarezOk.ru
189
I.
190
:
;
;
, .
;
1 0.
, , 0 .
, , .
'
'
'
Dim rate(1 To 4) As Integer
'
Dim comment (1 4) As String
'
Dim f As String
'
Dim q As Integer
Dim r As Integer
'
Sub NextQuestion()
If Not EOF(1) Then
'
'
Line Input #1, f
Label1.Caption = f
'
Line Input #1, f
www.WarezOk.ru
5.
191
Option1.Caption = f
Line Input #1, f
Optionl.Tag = f
' : 1 - , 0 - ;
' 0 1 Tag
' Option
Line Input #1, f
0ption2.Caption = f
Line Input #1, f
0ption2.Tag = f
Line Input #1, f
Option3.Caption = f
Line Input #1, f
Option3.Tag = f
'
Option1.Value
0ption2.Value
0ption3.Value
= False
= False
= False
Command1.Enabled = False
'
q = q + 1
' -
If EOF(1) Then Command1.Caption =
End If
End Sub
""
' //
Private Sub Command1_Click()
www.WarezOk.ru
I.
192
True
True
'
Seek #1, 1
Line Input #1, f
Form1.Caption = f
'
For i = 1 4 Step 1
Line Input #1, f
comment(i) = f
Line Input #1, f
rate(i) = f
Next
'
q = 0
r = 0
'
NextQuestion
Exit Sub
End If
If Command1.Caption =
""
Then
www.WarezOk.ru
5.
193
Option1.Visible
=
False
0ption2.Visible
=
False
Option3.Visible = False
Label1.Height = Label1.Height * 2
Label1.Caption=" ." + Chr(13) +
" : " + Format$(r)
+ " " + _
Format$(q) + "."
i = 1
While (r < rate(i))
i = i + 1
Wend
And
(i < 4)
'
Label1.Caption = Label1.Caption + Chr(13)+ comment(i)
Command1.Caption =
Else
NextQuestion
End If
End Sub
""
'
Private Sub Command2_Click()
Close #1
'
Unload Form1
End Sub
'
Private Sub Form_Initialize()
Label1.Font.Size = 10
FileName = CurDir + "\test.txt"
www.WarezOk.ru
I.
194
#1
'
'
'
'
For i = 1 4 Step 1
Line Input #1, f
comment(i) = f
Line Input #1, f
rate(i) = f
Next
'
q =
r =
'
NextQuestion
End Sub
'
Private Sub Option1_Click()
Command1.Enabled = True
End Sub
'
Private Sub Qption2_Click()
Command1.Enabled = True
End Sub
'
Private Sub Option3_Click()
Command1.Enabled = True
End Sub
www.WarezOk.ru
5.
195
"" . ,
. .
2 4. . 5.15, . 5.16.
, , . :
;
;
;
.
.
.
, ,
.
.
8.
,
.
.
-,
.
, ,
.
.
.
www.WarezOk.ru
I.
196
. 5.15.
. 5.16.
www.WarezOk.ru
5.
197
100
85
60
50
.
,
( \) ( ).
. . , , ( ) .
,
, .
:
\isaak.bmp
,0
,1
.0
,
.
'
'
'
Dim fileName As String
'
Dim summa As Integer
'
' ( )
Const N_LEV = 4
Const N_ANS = 4
www.WarezOk.ru
I.
198
""
'
Case 1:
summa = summa + score (otv)
Commandl.Enabled = False
Call resetForm
If Not EOF(l) Then
Call voprosToScr
Else
www.WarezOk.ru
5.
Close #1
Command1.Caption = "Ok"
Form1.Caption = ""
Command1.Tag =2
Command1.Enabled = True
Call itog
'
End If
'
Case 2:
Unload Me
End Select
End Sub
'
Private Sub Command2_Click()
Unload Me
End Sub
'
Private Sub Form_Initialize()
fileName = CurDir + "\test.txt"
'
Open fileName For Input As #1
Call resetForm
Call info
Call getLevel
'
'
Form1.ScaleMode = vbPixels
Command1.Tag = 0
Label1.Wordwrap = True
www.WarezOk.ru
199
I.
200
Label1.AutoSize = True
End Sub
'
Sub info()
Dim buf As String
Line Input #1, f
Form1.Caption = f
buf = ""
Do
Line Input #1,
If Mid(f, 1,
buf = buf +
Loop Until Mid(f,
' Mid(f, 1, 1)
' 1
'
'
'
f
1) ". Then _
f + vbCrLf
1, 1) = "."
f
'
Label1.Caption = buf
Conmand1.Caption = "Ok"
End Sub
'
Sub getLevel()
Dim i As Integer
i = 1
Do
Line Input #1, f
If Mid(f, 1, 1)
mes(i) = f
<>
"." Then
'
www.WarezOk.ru
5.
201
'
"."
'
Sub resetForm()
' Picture1
Option1.Visible = False
0ption2.Visible = False
Option3.Visible = False
Option4.Visible = False
Option1.Caption
Option2.Caption
Option3.Caption
Option4.Caption =
Option1.Value
0ption2.Value
0ption3.Value
0ption4.Value =
=
=
=
""
""
""
""
=
False
=
False
=
False
False
Image1.Visible = False
End Sub
'
Sub showPicture()
Dim w As Integer, h As Integer '
'
'
Dim resize As Single
www.WarezOk.ru
I.
202
Image1.Stretch = False
Image1.Top = Label1.Top + Label1.Height
'
w = Form1.ScaleWidth - Label1.Left * 2
h = Command1.Top - Label1.Top - Label1.Height
-7*2
'
' -
' ,
If Option1.Caption <> "" Then h = h - Option1.Height - 7
If Option2.Caption <> "" Then h = h - 0ption2.Height - 7
If 0ption3.Caption <> "" Then h = h - Option3.Height - 7
If 0ption4.Caption <> "" Then h = h - 0ption4.Height
- 7
' w h,
'
'
If (Image1.Height > h) Then
resize = Imagel.Width / Image1.Height
Image1.Stretch = True
Image1.Width = h * resize
Image1.Height = h
End If
'
If (Image1.Width > w) Then
Image1.Stretch = True
Image1. Width = w
Image1.Height = w / resize
End If
Image1.Visible = True
www.WarezOk.ru
5.
203
End Sub
'
Sub voprosToScr()
Dim i As Integer
Dim s As String, buf As String
Dim ifn As String
'
vopros = vopros +1
Form1.Caption = " "
buf = ""
+ Str(vopros)
'
DO
Line Input #1, f
If Mid(f, 1, 1) <> "." And Mid(f, 1, 1) <> "\"
_Then
buf = buf + f + " "
End If
Loop Until Mid(f, 1, 1) = "." Or Mid(f, 1, 1) =
"\"
'
Label1.Caption = buf
' , ,
'
' ,
'
If Mid(f, 1. 1) <> "\" Then
Image1.Tag =0
'
Else
'
Imagel.Tag =1
ifn = Mid(f, 2)
' Mid(f, 2) - f
' 2-
www.WarezOk.ru
I.
204
'
' ( )
On Error Resume Next
Image1.Picture = LoadPicture(CurDir + "\n + ifn)
If Err Then Image1.Tag =0
End If
i = 1
'
DO
buf = ""
Do
'
Line Input #1, f
If Mid(f, 1, 1) "." And Mid(f, 1, 1) <> ","
_
Then
buf = buf + f + " "
End If
Loop Until Mid(f, 1, 1) = "." Or Mid(f, 1, 1) = ","
'
score(i) = Int(Mid(f, 2, 1))
Select Case i
Case 1: Option1.Caption = buf
Case 2: Option2.Caption = buf
Case 3: Option3.Caption = buf
Case 4: Option4.Caption = buf
End Select
i = i + 1
Loop Until Mid(f, 1, 1) = "."
'
www.WarezOk.ru
5.
205
' , -
If Image1.Tag = 1 Then
'
Call showPicture
End If
'
If Option1.Caption <> "" Then
If Image1.Tag = 1 Then
Option1.Top = Image1.Top + Image1.Height + 7
Else: Option1.Top = Label1.Top + Label1.Height + 7
End If
Option1.Visible = True
End If
If Option2.Caption <> "" Then
Option2.Top = Option1.Top + Option1.Height + 7
0ption2.Visible = True
End If
If 0ption3.Caption <> "" Then
0ption3.Top = 0ption2.Top + Option2.Height + 7
Option3.Visible = True
End If
If 0ption4.Caption <> "" Then
0ption4.Top = 0ption3.Top + Option3.Height + 7
0ption4.Visible = True
End If
End Sub
'
Sub itog()
Dim i As Integer
Dim buf As String
www.WarezOk.ru
I.
buf =
206
i = 1
While (summa < level(i))
i = i + 1
Wend
And
(i < N_LEV)
www.WarezOk.ru
6
Visual Basic ,
.
( ) visData Visual Data
Manager, Visual Basic.
,
,
.
. ODBC
ODBC,
( ).
1.
""
(. . 6.1). . 6.2.
Adodc, Command1 ( ), Command2 ( ) Command3 ( ).
www.WarezOk.ru
I.
208
. 6.1. ,
""
. 6.2. ,
""
"" .
Microsoft Access
www.WarezOk.ru
6.
209
Title
Cost
Text
50
Currency
Comment
Photo
Memo
Text
30
()
'
Const imH = 3600
Const imW = 3600
Dim gPath As String '
'
Private Sub Form_Load ()
Dim p As Integer
'
'
Text1.MaxLength =50
Text2.MaxLength = 8
Text4.MaxLength =30
' Text3 , . .
' - Memo
Adodc1.ConnectionString =
"DSN=stock"
'
DataEnviroranent1.Connection1.ConnectionString =
www.WarezOk.ru
I.
210
Adodc1.ConnectionString
DataEnvironment1.Connection1.Open
gPath = DataEnvironmentl.Connectionl.DefaultDatabase
DataEnvironment1.Connection1.Close
' DefaultDatabase - ( )
' ,
= InStrRev(gPath, "\") ' (
' )
gPath = Mid(gPath, 1, )
'
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "Select
Adodc1.Refresh
* From stock"
'
If Adodc1.Recordset.RecordCount = 0 Then
' Command2.Enabled = False
'
""
'
Command3.Enabled = False
' ""
'
' ,
' " ",
1
. ,
' .
' - ,
' , . .
' , .
1
Adodc1.Recordset.AddNew
End If
www.WarezOk.ru
6.
211
End Sub
' " "
Private Sub Command1_Click{)
Adodc1.Recordset.AddNew
'
'
Image1.Picture = LoadPicture()
Label5.Visible = False
Text1.SetFocus
End Sub
' ""
Private Sub Command2_Click()
'
If Adodc1.Recordset.RecordCount = 0 Then
Command3. Enabled = True '
'
End If
" "
Adodc1.Recordset.Update
'
'
'
'
'
.
, ,
, . . .
Adodc1.Recordset.Bookmark=Adodc1.Recordset.LastModified
End Sub
' " "
Private Sub Command3_Click()
www.WarezOk.ru
I.
212
Dim r
r = MsgBox(" ?", vbQuestion + vbOKCancel,
" ")
If r = vbOK Then
If Adodc1.Recordset.RecordCount <> 0 Then
Adodc1.Recordset.Delete
If Adodc1.Recordset.EOF Then
Adodc1.Recordset.MoveNext
Else
Adodc1.Recordset.MoveLast
End If
End If
If Adodc1.Recordset.RecordCount =
Adodc1.Recordset.AddNew
Command2.Enabled = False
Command3.Enabled = False
End If
End If
End Sub
0 Then
' Label 6
'
Private Sub Label6_Change()
Call ShowPicture_
End Sub
'
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then Text2.SetFocus
End Sub
'
www.WarezOk.ru
6.
213
'
'
Select Case KeyAscii
Case Asc(O) To Asc(9)
'
Case 9, 8
' <Tab>,<Backspace>
Case 13
Text3.SetFocus
' <Enter>
Case Asc("."), Asc(",")
KeyAscii = Asc(".H)
n = InStrd, Text2.Text, ".")
If n <> 0 Then KeyAscii =0
'
Case Else
KeyAscii = 0
End Select
End Sub
'
Private Sub Text4_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Call ShowPicture_
'
Command2.SetFocus
' ""
End If
End Sub
' Imagel
Sub ShowPicture_()
Dim kx,
ky,
k
'
'
no x,
www.WarezOk.ru
I.
214
Image1.Visible = False
Image1.Stretch = False
Label5.Visible = False
If Label6.Caption = "" Then
Label5.Caption = " ."
Label5.Visible = True
Exit Sub
End If
On Error GoTo er
Image1.Picture = LoadPicture(gPath + Label6.Caption)
Image1.Stretch = False
' :
'
If Image1.Height > imH Then
ky = im / Imagel.Height
Else
ky = 1
End if
'
If Imagel.Width > imW Then
kx = imW / Imagel.Width
Else
kx = 1
End If
If ky < kx Then
= ky
Else
www.WarezOk.ru
6.
215
=
End If
Image1.Width = imW *
Image1.Height = imH *
Image1.Stretch = True
Image1.Visible = True
er: '
Label5.Caption = " "
gPath + Label6.Caption
Label5.Visible = True
+ vbCrLf +
End Sub
2. " "
SQL-
. ( dBase)
Visual Data Manager. , adrbk.dbf (. . 6.2),
adrbk
ODBC. Adodc, DataGrid. . 6.3.
. 6.3 6.4
Adodc1 DataGrid1.
Name
Tel
Cell
Email
Text
Text
Text
Text
15
15
15
30
www.WarezOk.ru
I.
216
6.4.
DataGridl
DataSourcel
Adodcl
www.WarezOk.ru
6.
217
'
Private Sub Command1_Click()
Dim Keyword As String
KeyWord = InputBox(" " + vbCrLf
+ _
"( )", "", " ")
If Keyword <>
'
'
'
""
Then
:
Select * From Adrbk Where Name Like 'Ky%'
Select * From Adrbk Where Name Like '%%'
Adodc1.RecordSource =
"SELECT * FROM adrbk where Name like " + _
Chr(39) + "%" + Keyword + "%" + Chr(39)
Adodcl.Refresh '
End If
End Sub
'
Private Sub Command2_Click()
Adodc1.RecordSource = "SELECT
' MsgBox Adodc1.RecordSource
Adodc1.Refresh
End Sub
'
www.WarezOk.ru
I.
218
. 6.4. ""
( )
. 6.5. ""
www.WarezOk.ru
6.
219
. 6.5.
Adodc,
DataGrid.
Adodc
DataGrid . 6.6 6.7, dp
( ) . 6.5.
6.5. ""
Fwhen
Date/Time
Fwhat
Text
50
6.6. Adodc1
ConnectionString
DSN=dp
( )
CoinmandType
adCmdText
SQL-
RecordSource
SELECT fwhat,
fwhen
FROM
dp
ORDER
BY
SQL-:
fwhen
fwhat
dp
fwhen
fwhen
6.7. DataGridi
DataSource1
Adodc1
Option Explicit
Dim myMonthName (12)
Private Sub Form_Initialize()
Dim Today As Date
myMonthName(1)
"" : myMonthName(2)=""
www.WarezOk.ru
I.
220
myMonthName(3)="
myMonthName(5)="
myMonthName(7)="
myMonthName(9)="
myMonthName(11)=
Today = Date
Label1.Caption = " " + Str(Day(Today)) + _
myMonthName(Month(Today)) + ", " + _
WeekdayName(Weekday(Today,vbMonday),False,0)
' .
' .
' 300 70 - ( )
DataGrid1.Columns(0).Width=70* Screen.TwipsPerPixelX
DataGrid1.Columns(1).Width=300* Screen.TwipsPerPixelX
' <Tab>
'
DataGrid1.TabAction = dbgGridNavigation
End Sub
' ,
Private Sub Commandl_Click()
Dim p As String
Dim n
'
'
,
'
Label2.Caption =
" "
= Format(Date, "mm/dd/yy")
www.WarezOk.ru
6.
221
= Replace(p, ".",
= "#" + + "#"
"/")
")"
If Adodc1.Recordset.RecordCount = 0 Then
MsgBox " ",
vbOKOnly, ""
End If
End Sub
'
Private Sub Command2_Click()
Dim sDay As Date
Dim fDay As Date
Dim dow As Integer
'
()
' SQL-
Dim pi As String
Dim p2 As String
sDay = Date
sDay = sDay +
fDay = sDay
dow = Weekday(sDay,
If dow >= 5 Then
Label2.Caption =
Else
Label2.Caption =
vbMonday)
" "
" "
www.WarezOk.ru
I.
End
222
If
p2
p2
= Format(fDay, "mm/dd/yy")
= "#" + Replace(p2, ".",
"/")
"#"
"#"
'
If Adodc1.Recordset.RecordCount = 0 Then
MsgBox " "
vbCrLf + _ ", _
vbOKOnly, ""
End If
End Sub
'
Private Sub Command3_Click()
www.WarezOk.ru
+ _
6.
223
'
()
' SQL-
Dim p1 As String
Dim p2 As String
" "
Label2.Caption =
p1 = Format(sDay, "mm/dd/yy")
p1 = "#" + Replace(pi, ".",
"/")
"#"
p2
p2
"/")
"#"
= Format(fDay, "mm/dd/yy")
= "#" + Replace(p2, ".",
' SQL-
Adodc1.RecordSource = "SELECT DP.* From DP " + _
"WHERE ( DP.FWHEN >= " + p1 + _
") and ( DP.FWHEN <= " + p2 + ") ORDER BY
fwhen"
Adodc1.Refresh
'
If Adodc1.Recordset.RecordCount = 0 Then
MsgBox " ",
vbOKOnly, ""
www.WarezOk.ru
I.
224
End If
End Sub
' , ( )
Private Sub Command4_Click()
Label2.Caption = ", "
Adodcl.RecordSource =
' "SELECT fwhen,fwhat FRCM
Adodc1.Refresh
End Sub
(dp)
ORDER BY fwhen"
' .
Private Sub Command5_Click()
Dim sDay As Date '
Dim fDay As Date '
Dim dow As Integer
'
()
' SQL-
Dim p1 As String
Dim p2 As String
Label2.Caption =
" "
sDay = Date
dow = Weekday(sDay, vbMonday)
sDay = sDay + 8 - dow
fDay = sDay +
'
'
: #mm/dd/yy#
www.WarezOk.ru
6.
225
".",
= Format(fDay, "mm/dd/yy")
= "#" + Replace(p2, ".",
"/")
"/")
"#"
"#"
' SQL-
Adodc1.RecordSource = "SELECT DP.* From DP " + _
"WHERE ( DP.FWHEN >= " + p1 + _
") and (DP.FWHEN <= " +p2+ ") ORDER BY fwhen"
Adodc1.Refresh
'
If Adodc1.Recordset.RecordCount = 0 Then
MsgBox " " + _
" ", _
vbOKOnly, ""
End If
End Sub
www.WarezOk.ru
www.WarezOk.ru
II
www.WarezOk.ru
II.
228
,
, .
www.WarezOk.ru
Microsoft Visual Basic 6.0.
.
, Visual Basic (width, Height) (Left, )
(twip).
.
.
( Form) .
(. 7.1) .
7.1. Form ()
Name
Caption
Left
www.WarezOk.ru
II.
230
7.1 ()
Width
Height
ScaleWidth
,
.
,
ScaleHeight
() ,
.
,
ScaleMode
.
Width Height,
BorderStyle
() ( ). (sizable),
(FixedSingle) (None).
FixedSingle,
,
( Maximize) ( Minimaze). None, . .
FixedDialog, " "
( , ,
)
Icon
()
BackColor
. ,
.
.
ForeColor
www.WarezOk.ru
7.
231
7.1 ()
FillColor
Filistyle
() :
Transparent (l) ( );
Solid
()
;
HorizontalLine
(2)
;
VerticalLine
() . FillColor
DrawMode
. ,
Blackness (1),
(
, Print)
DrawWidth
Drawstyle
, :
Solid (0) ; Dash (l) ; Dot (2) ; Dash-Dot
() "-"; Dash-Dot-Dot (4)
"--";
Transparent
(5)
""
Font
. , ,
(,
Print)
MaxButton
MinButton
Label
Label (. 7.1)
. (. 7.2)
.
www.WarezOk.ru
II.
232
. 7.1. Label
7.2. Label
Name
Caption
Left
Height
width
AutoSize
Wordwrap
, ,
,
Alignment
LeftJustify
(),
Center
(2)
RightJustify (1)
Font
, .
Name, Size FColor
,
BackColor
. ,
www.WarezOk.ru
7.
233
7.2 ()
Backstyle
.
(opaque)
""
(Transparent).
Opaque,
BackColor
visible
( False)
( True)
TextBox
TextBox (. 7.2) . . 7.3.
. 7.2. TextBox
7.3. TextBox
Name
. ,
,
Text
Left
Top
Height
www.WarezOk.ru
II.
234
7.3 ()
Width
Font
Locked
.
False,
MultiLine
ScrollBars
:
Vertical ;
Horizontal ; Both
; None
Visible
(False)
(True)
CommandButton
CommandButton (. 7.3) . . 7.4.
7.4. CommandButton
Name
Caption
www.WarezOk.ru
7.
235
7.4 ()
Left
Height
Width
Enabled
Visible
Style
Picture
DisabledPicture
DownPicture
ToolTipText
.
True, .
False,
, . .
( False)
( True)
: "" (standard) "" (Graphical).
,
""
.
, Style
Graphical
"" . ,
Style Graphical, a
Enabled False
""
. , style Graphical
,
www.WarezOk.ru
II.
236
CheckBox
CheckBox (. 7.4)
. . 7.5.
. 7.4. CheckBox
7.5. CheckBox
Name
Caption
:
(
( "")
Checked
""); Unchecked
Left
Height
width
( )
Font
Visible
(
False) (
True)
www.WarezOk.ru
7.
237
OptionButton
OptionButton (. 7.5)
,
. . 7.6.
. 7.5. OptionButton
7.6. OptionButton
Name
Caption
,
.
True,
False
,
,
Tag
Visual Basic .
Left
Height
width
( )
Font
visible
(
False) (
True)
www.WarezOk.ru
II.
238
ListBox
ListBox (. 7.6) , .
. 7.7.
. 7.6. ListBox
7.7. ListBox
Name
BackColor
. ,
ForeColor
List
ListCount
Sorted
( True)
Listindex
MultiSelect
. None (),
.
, simple (l), , , .
. Extended (2),
<Shift> <Ctrl> (
<Shift>
, )
www.WarezOk.ru
7.
239
7.7 ()
style
() .
CheckBox (1),
Checkbox.
. ,
Standard (0),
Left
Height
width
Font
visible
(
False) (
True)
ComboBox
ComboBox (. 7.7)
. . 7.8.
. 7.7. ComboBox
www.WarezOk.ru
II.
7.8. ComboBox
Name
Font
BackColor
.
,
ForeColor
List
ListCount
Listlndex
, .
, -1.
Style
() .
DropdownCombo (),
( ,
). SimpleCombo (l), ,
.
DropdownList (2),
Text
(, )
Sorted
( True)
Locked
. ( )
www.WarezOk.ru
240
7.
241
7.8 ()
Left
Height
width
Visible
(False)
(True)
Timer
Timer (. 7.8) Timer.
. 7.9.
. 7.8. Timer
7.9. Timer
Name
Interval
Timer.
Enabled
(/).
( True) ( False) Timer
www.WarezOk.ru
II.
242
DriveListBox
DriveListBox (.7.9) , .
. 7.10.
. 7.9. DriveListBox
7.10. DriveListBox
Name
Font
BackColor
.
,
ForeColor
List
.
(, :)
ListCount
List index
, .
, -1.
Left
www.WarezOk.ru
7.
243
7.10 ()
Height
width
visible
( False) ( True)
DirListBox
DirListBox (. 7.10) . . 7.11.
. 7.10. DirListBox
7.11. DirListBox
Name
Font
BackColor
.
,
ForeColor
List
() .
www.WarezOk.ru
II.
244
7.11 ()
ListCount
Listindex
,
.
. , Dirl,
-1.
( ), -2.
1
Path
Left
Height
Width
visible
( False) ( True)
FileListBox
FileListBox (. 7.11) .
. 7.12.
. 7.11. FileListBox
www.WarezOk.ru
7.
245
7.12. FileListBox
Name
Font
BackColor
.
,
ForeColor
List
( ) .
(.)
Listcount
List
Index
Path
Archive
,
""
Hidden
,
""
Readonly
"
System
,
""
Normal
"",
" ",
Left
,
" -
www.WarezOk.ru
II.
246
7.12 ()
Height
width
Visible
(
False) ( True)
PictureBox
PictureBox (. 7.12)
. () . . 7.13.
. 7.12. PictureBox
7.13. PictureBox
Name
Picture
( BitMap), .
( LoadPicture)
AutoSize
(True) (False)
( ) ,
www.WarezOk.ru
7.
247
7.13 ()
BorderStyle
BackColor
. ,
Font
ForeColor
Print ,
()
FillColor
(),
( )
FillStyle
, :
Solid (0) ; HorizontalLine (2)
; VerticalLine (3)
; Transparent (1)
"" .
FillColor
DrawStyle
,
:
Solid () ; Dash (1) ; Dot (2) ; Dash-Dot
(3) "-"; Dash-Dot-Dot (4) "--"; Transparent (5) ""
DrawWidth
ScaleWidth
,
. ScaleMode
ScaleHeight
,
.
ScaleMode
www.WarezOk.ru
II.
248
7.13 ()
ScaleMode
. Width
Height (
)
Left
Top
Height
Width
Visible
(
False) ( True)
Image
image (. 7.13)
. pictureBox ,
(
image . 7.14.
).
. 7.13. Image
7.14. image
Name
www.WarezOk.ru
7.
249
7.14 ()
Picture
BorderStyle
( BitMap), .
( LoadPicture)
:
FixedSingle
(1)
( ); None ()
Stretch
( ) . True
(
, ). False
Left
Height
width
visible
(
False) (
True)
Shape
shape (. 7.14) (, , ), .
, . . . . 7.15.
www.WarezOk.ru
II.
250
. 7.14. Shape
7.15. shape
Name
Shape
BackColor
. ,
BackStyle
:
Transparent
, Opaque (l)
BorderColor
( )
BorderStyle
( ): Solid
(0) ; Dash (l) ;
Dot (2) ; Dash-Dot ()
"-";
Dash-Dot-Dot
(4)
DrawWidth
FillColor
Fillstyle
(
):
Transparent
(l)
""
( ), Solid (0) ;
HorizontalLine
(2)
;
VerticalLine
()
.
FillColor
www.WarezOk.ru
()
(-
7.
251
7.15 ()
Left
Height
width
Visible
( False)
( True)
Line
Line (.7.15) ""
, . . . . 7.16.
. 7.15. Line
7.16. line
Name
Border-Color
Border
Style
www.WarezOk.ru
II.
252
7.16 ()
DrawWidth
XI
Y1
Y2
visible
( False)
( True)
UpDown
UpDown (. 7.16) ,
, ( )
-. UpDown
-.
UpDown . 7.17.
. 7.16. UpDown
7.17. UpDown
Name
Value
. Up () Down
()
www.WarezOk.ru
7.
253
7.17 ()
Increment
- Value
Min
Value
BuddyContr1
, - (, Label TextBox)
BuddyProperty
, BuddyControl,
-
(caption,
Label)
AutoBuddy
-, -.
Label,
BuddyProperty Caption
SyncBuddy
(True)
Value -
Orientation
( ) : OrientationVertical (0)
(,
);
OrientationHorizontal
(1)
(, )
Wrap
False, Value,
Up. Down.
True,
,
Value
Enabled
(
True)
( False)
www.WarezOk.ru
II.
254
7.17 ()
Left
Height
width
visible
( False) (
True)
CommonDialog
CommonDialog (. 7.17) Windows (, , ,
, ).
. 7.18. , (. 7.19).
. 7.17. CommonDialog
7.18. CommonDialog
Name
DialogTitle
www.WarezOk.ru
7.
255
7.18 ()
FileName
, .
, . .
Cancel,
Filter
. , () . ,
Filter index
. 1
Flags
HelpFile
help-,
7.19. CommonDialog
ShowOpen
ShowSave
ShowColor
ShowFont
ShowPrinter
ShowHelp
MMControl
. 7.18. MMControl
www.WarezOk.ru
II.
256
. 7.19. MMControl
7.20. MMControl
Name
DeviceType
: CDAudio
CD;
WaveAudio
WAV-;
AVIVideo AVI- .
Command
TimeFormat
FileName
PlayEnabled
Play
(
True)
False).
PlayVisible
Play
(
False)
(
True).
Left
Height
Width
Visible
( False)
( True)
www.WarezOk.ru
,
PictureBox.
( ) :
.
.
, ,
, .
, " ", .
.
Print
[.]Print String
Print string
( , currentx currenty). Font (, ), , -
ForeColor .
:
Font.Name = "Arial"
Font.Size = 12
www.WarezOk.ru
II.
ForeColor
RGB(0,
ScaleMode =
258
255)
'
CurrentX =10
CurrentY =
Print
20
Line
[.]Line [Step] (xl, yl) [Step]-(x2, y2),[Color], [B][F]
Line ( ).
xl, yl 2, 2
( ).
( )
ForeColor (
Color).
Drawwidth
Drawstyie , .
step , .
color , ,
( ).
, .
F , , .
:
ScaleMode
Line
(10,
'
20)-(100,
20)
'
Line
(10,30)-(100,30),RGB(255,0,0)'
Line
(10,
Line
(10,
60)-(100,
Line
(10,
80)-(100,
40)-(100,
50),
'
70),RGB(0,127,0),
90),
RGB(0,
127,
www.WarezOk.ru
'
0),
BF
8.
259
Circle
[.]Circle [Step] (x,y), Radius, [Color,Start,End,Aspect]
circle , (
Aspect) . ForeCoior , ( color).
( ) Drawwidth Drawstyle , .
step , .
Radius , Aspect, .
color ( ForeCoior ).
start , End
. start
. .
:
r=2/(/360),
: r , ,
- "" (3.1415926).
Aspect .
Aspect 1, ( 0, ). Aspect
1,
.
:
pi =
3.1415926
'
""
ScaleMode = 3
'
Circle
50),
(100,
30
'
www.WarezOk.ru
II.
260
50),
30,
Circle (150,
50),
30,
0,
pi
Circle (100,
120),
30,
0.5
Circle (100,
120),
30,
RGB(255,
/
0,
'
0), pi / 2,
'
'
'
RGB
RGB(r,g,b)
RGB
r,
g,
RGB-
-,
79
79
47
255
36
255
127
112
219
147
66
66
111
-,
127
255
-,
147
112
219
159
95
159
50
50
205
107
142
35
140
23
23
www.WarezOk.ru
8.
261
8.1 ()
RGB-
173
234
234
112
219
219
143
188
143
140
120
83
166
125
61
255
127
35
107
142
95
159
159
133
94
66
233
194
166
166
128
100
84
84
84
153
204
50
147
219
112
82
127
118
-,
74
118
110
66
111
66
219
219
112
234
234
174
205
127
50
78
47
47
217
217
243
142
35
35
255
127
50
205
50
166
42
42
181
166
www.WarezOk.ru
II.
262
8.1 ()
RGB-
35
153
50
205
()
228
120
51
184
115
51
35
142
104
89
89
171
50
153
204
255
110
199
156
56
176
222
255
28
174
33
94
33
142
107
35
205
205
205
92
64
51
127
255
127
255
107
35
142
209
146
117
47
47
79
217
135
25
216
216
191
188
143
143
, -
133
99
99
219
147
112
-,
235
142
www.WarezOk.ru
199
35
158
8.
263
8.1 ()
RGB-
-,
151
105
79
143
143
189
219
112
219
168
192
168
217
168
217
230
232
250
192
192
192
234
173
234
111
66
66
50
205
153
207
181
59
112
147
219
142
35
107
47
79
47
92
64
51
135
31
120
-,
47
79
79
35
35
142
204
50
153
-,
219
112
147
79
47
79
159
159
95
216
80
51
23
107
66
38
217
191
217
www.WarezOk.ru
216
25
.
.
.
inputBox, MsgBox.
InputBox
InputBox(Prompt[,Title][,Default][,X][,Y][,HlpFile,C
nt])
inputBox ,
. .
Prompt - ,
.
Title .
, ,
.
Default ( ) ,
(
www.WarezOk.ru
9.
265
, ,
.
Y
.
.
MsgBox
MsgBox(Prompt[,MsgType
).
,
. , -
[,Title][,HFile,Cnt])
MsgBox . ,
.
Prompt ( ) .
MsgType ( )
, .
MsgType
:
Msg + Btn
: Msg , Btn (), . :
vblnformation (64) , vbCritical (1)
. (): vbOKOnly ()
Ok; vbOKCancel (l) Ok Cancel; vbYesNo (4) Yes No.
, .
Title .
, , .
HipFile , cnt . ,
<F1>.
www.WarezOk.ru
II.
266
. 9.1 .
9.1.
Abs (N)
() N
Sqr (N)
Exp(N)
Sgn(N)
N. N
, 1, ,
Rnd[ (N) ]
0 (N-1).
N , [0,1[. Rnd
Randomize
int (N)
. "" . N ,
, N. :
Int (5. 85) =5, Int (-5.85) =-6
Fix(N)
, N. :
Fix(5.85)=5, Fix(-5.85)=-5
isNumeric
(S)
, S . s ( ) , True.
False. :
IsNumeric ("5, 85") True,
IsNumeric ("5, 8 5") True,
IsNumeric ("hello") False
www.WarezOk.ru
9.
267
9.1 ()
Log(N)
( ). :
Log(N) / Log(lO)
Cos()
Tan()
Atn(cx).
Sin (a)
(g
* 3.14159265358979)/180
: g ; 3.14159265358979 .
. 9.2
.
9.2.
Boolean.
CBool (Expression)
:
CBool (5 > 4)
True,
CBool (5 = 4)
False
CDbl (Expression)
Double
Clnt (Expression)
Integer
CLng (Expression)
Long
www.WarezOk.ru
II.
268
9.2 ()
CSng (Expression)
CVar (Expression)
CDate (Expression)
cstr (Expression)
Single
Variant
Date
. 9.3
, .
9.3.
Chr(Code)
Asc(ch)
lnStr( [start, ]
stringl, string2
[,Compare])
Chr ANSI-cviMBon,
Code. Code 0 255
Ch.
,
instr
( ) . Start
. () .
,
0.
start
,
. ,
.
Sringl , .
Sring2 (),
Sringl.
www.WarezOk.ru
9.
269
9.3 ()
Compare
: TextCompare (1) ,
BinaryCompare
(0)
. ,
. :
InStr
(1,
"Hh",
"h",
vbBinaryCompare)
2,
InStr
(1,
l
InStrRev(Stringl,
String2
[
,Start
[, Compare] )
"Hh",
"h",
vbTextCompare)
inStrRev
)
.
start
.
()
(
).
, 0.
start
,
. ,
.
Sring1,
Sring2
(),
Sringl.
Compare
:
TextCompare
(1)
,
BinaryCompare
(0)
.
,
.
:
InStrRev
(1,
"HHt",
"ht",
vbBinaryCompare) 0,
InStr
(1,
"Hht",
"ht",
vbTextCompare)
www.WarezOk.ru
II.
270
9.3 ()
Len(S)
Len S
( )
LCase(S)
LCase
s .
UCase(S)
UCase s .
Left (S, L)
Left (
, ) L
S. L , s,
s
Right (S, D
Right ( , ) L s. L ,
s,
s
LTrim(S)
LTrim
RTrim(S)
RTrim
Trim(S)
Trim
Space (N)
,
N Ch
strReverse(S)
"" s. :
StrReverse("Hello") olleH
www.WarezOk.ru
9.
271
9.3 ()
Val (S)
CDbl(S)
Val ,
s.
,
,
.
. ,
, -
.
, val . : Val( 123 45) = 12345;
Val(123,45) = 123;
Val(123.45) = 123.45;
Val("Text") = 0
CDbl , S.
,
,
.
. ,
-
,
( ).
, ().
:
CDbl(123 45) = 12345;
CDbl(123,45) = 123,45;
CDbl(123.45) = 123
. 9.4
.
www.WarezOk.ru
II.
272
9.4.
Date
Tirne
Now
Year (Date)
Month (Date)
MonthName (Month [,
Abbreviate])
(3 )
( Month
1 12;
Abbreviate
True,
, False )
Day (Date)
( 1 31)
Weekday (Date,
[FirstDayOfWeek] )
Date.
FirstDayOfWeek
: vbUseSystem (0) ,
Sunday
(1)
,
Monday (2) . .
WeekdayName (Weekday,
Abbreviate
Firs tDayOfWeek)
(2 )
. Weekday
1 7;
Abbreviate
True,
, False
FirstDayOfWeek
: vbUseSystem () ,
Sunday
(l),
Monday
(2) . .
www.WarezOk.ru
9.
273
9.4()
Hour(Time)
Minute (Time)
Second
Time
(Time)
Timer
Time
Time
. 9.5 ,
.
9.5.
Open PathName
For Mode
[Access Am]
[Lock]
As
#FileNumber
[Len = reclen]
Open
/. PathName ,
. Mode
: input (),
Output (), Binary /
, Random /
. Am , : Read (), Write (), Read Write
(/). FileNumber (
1 511)
.
www.WarezOk.ru
II.
274
9.5 ()
reclen
( ), (Binary)
Seek #FileNumber,
Position
Seek
/ ,
(Binary). FileNumber
. Position ( ),
Seek( #FileNumber
Seek /
FreeFile[(Range)
FreeFile ,
(
FileNumber Open)
Get
#FileNumber
,
[RecNumber]
,
VarName
Get :
FileNumber ()
, RecNumber (
, Binary),
, VarName ,
#FileNumber
,
[RecNumber]
,
VarName
Put :
FileNumber ()
, RecNumber (
, Binary),
, VarName ,
Put
www.WarezOk.ru
9.
275
9.5 ()
Line Input
#FileNumber,
VarName
Input
input
. FileNumber ,
VarList ,
. :
Input #1, a,b,c
#FileNumber,
VarList
Input(Number,
#FileNumber)
input
,
Input Binary. Number
,
FileNumber . :
IDChar = Input(1,#1)
#FileNumber,
[OutputList]
FileNumber . OutputList ( ) . :
Print #1, "a="+Str(a),"b="+Str(b)
Write
#FileNumber,
.
OutputList
( ).
. :
Write #1, ,
[OutputList]
LOF(FileNumber)
FileLen
( )
EOF(FileNumber)
LOF
( )
FileLen(Pa thName)
EOF /.
True,
( )
www.WarezOk.ru
II.
276
9.5 ()
Dir[,(Path
[,Attributes
])]
Dir
Path
Attributes.
(),
Path
(,
c:\temp\*.bmp),
,
.
Dir
.
:
fn
=Dir(":\temp\*.bmp")
fn = fn + Chr(13) + Dir
Attributes ()
: Normal (), Readonly (l),
Hidden (2), System (4), Directory
(16) .
:
Dir
("e:\test.txt")
"test.txt",
:;
Dir
("e:\t\*.txt")
txt;
Dir
("e:\",vbDirectory)
(
:
CurDir
(
CurDir
ChDir
Path
ChDir
www.WarezOk.ru
test.txt
e:\t
()
()
9.
277
9.5 ()
MkDir Path
MkDir .
Path .
RmDir path
RmDir .
Path
,
. , , .
(
Kill),
Kill PathName
Kill .
PathName
(
, . , , . :
Kill ":\temp\*.tmp"
www.WarezOk.ru
10
Windows.
10.1.
Click
Dblciick
MouseDown
Mouseup
MouseMove
Keypress
KeyDown
. KeyDown KeyPress
, , (
u)
KeyUp
Load
(,
).
Unload
www.WarezOk.ru
9.
279
. 10.1 ()
Paint
,
, ,
. ()
GotFocus
LostFocus
Resize
www.WarezOk.ru
-,
. .
"Visual Basic.
"
CD-ROM ,
.
.
()
CD-ROM. , , ,
ODBC. ODBC Windows ( | |
| | ).
, ,
.
www.WarezOk.ru
:
CheckBox 236
ComboBox 239
CommandButton 234
Common Dialog 254
DirListBox 243
DriveListBox 242
FileListBox 244
Image 248
Label 231
Line 251
ListBox 238
MMControl 255
OptionButton 237
PictureBox 246
Shape 249
TextBox 233
Timer 241
UpDown 252
M
266
Print 257
:
"" 180
"" 25
"CD-" 101
"ID3vl Tag Editor" 118
"-" 107
"" 176
"" 217
" " 215
" Windws" 99
" 15" 141
" Puzzle" 147
"
" 154
" " 165
" " 135
"" 43, 46, 50
""58
" " 129
"" 195
" " 39, 40
85
87
9
6, 7, 8
92
133
:
14
. 16, 18
11
22
www.WarezOk.ru
66
"" 91
69
72
61
77, 81
55
62
97
89
:
:
CheckBox 236
ComboBox 239
CommandButton 234
CommonDialog 254
DirListBox 243, 244
DriveListBox 242
Image 248
Label 231
Line 251
ListBox 238
MMControl 255
OptionButton 237
PictureBox 246
Shape 249
TextBox 233
Timer 241
UpDown 252
229
T
229
229
:
271
273
268
267
InputBox 264
MsgBox 265
www.WarezOk.ru
www.WarezOk.ru