Visual Basic NET ( 3)

         

ListView


ListView . Windows ListView . , Windows . , Windows.

() , True LabelEdit ListView. SubItems , ( InputBox).

ListView . .

136 . , . , . .

ListView . . :

StarDraft

300

UntiReal

500

Suake

200

Feroes III

800

5 , 5 . 20.11. , LV :

Dim i As Integer '

Private Sub (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles .Click



Dim As New System.IO.StreamWriter("E:\VB\.txt")

For i = 0 To LV.Items.Count

- 1

.WriteLine(LV.Items(i).SubItems(0).Text) ' 1 i-

.WriteLine(LV.Items(i).SubItems(1).Text) ' 2 i-

.WriteLine(LV.Items(i).SubItems(2).Text) ' 3 i-


Next

.Close()

End Sub

: ListView , 16.2, . . Items Count, , . 0, LV.Items.Count-1. i , . .

ListView . LV. ( . 20.13). . :

Private Sub (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles .Click

' :

Do Until LV.Items.Count = 0 ' ,

LV.Items(0).Remove() ' 0 ,

Loop

' :

Dim As New System.IO.StreamReader("E:\VB\.txt")

i = 0

Do While .Peek() <> -1

' :

LV.Items.Add(.ReadLine)

LV.Items(i).SubItems.Add(.ReadLine) '

LV.Items(i).SubItems.Add(.ReadLine) '

i = i + 1

Loop

.Close()

End Sub

: LV.Items(0).Remove() , . Items.Add, Items, SubItems.Add, SubItems.



ListView. ListView , . ListView . , , , . , True MultiSelect.

:

Private Sub (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles .Click

' :

LV.Items.Add(InputBox(" "))

' :

LV.Items(LV.Items.Count - 1).SubItems.Add(InputBox(" "))

LV.Items(LV.Items.Count - 1).SubItems.Add(InputBox(" (-)"))

End Sub

: LV.Items.Count-1 .

:

Private Sub (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles .Click

For i = LV.Items.Count - 1 To 0 Step -1

If LV.SelectedIndices.Contains(i) Then

LV.Items(i).Remove()

End If

Next

End Sub

: ListView SelectedItems SelectedIndices. . SelectedIndices Contains, , ListView ( i) .

If LV.SelectedIndices.Contains(i) Then

: i, .

, , . , , , , , .

:

Private Sub (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles .Click

Dim As String = InputBox(" ")

Dim As String = InputBox(" ")

Dim As String = InputBox(" (-)")

For i = 0 To LV.Items.Count - 1

If LV.SelectedIndices.Contains(i) Then

LV.Items(i).SubItems(0).Text =

LV.Items(i).SubItems(1).Text =

LV.Items(i).SubItems(2).Text =

End If

Next

End Sub

: .


TreeView


. , 4 .

. , . Form1_Load . , ? . (15.9). , , , , .

:

Dim K As Integer = 0 ' 4-

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

(TreeView1)

Debug.WriteLine(K)

End Sub

Sub (ByVal As Object)

Dim As TreeNode

For Each In .Nodes

If Len(.Text) = 4 Then K = K + 1

()

Next

End Sub

, . .

: , , . . - , .

For Each In .Nodes

.

If Len(.Text) = 4 Then K = K + 1

, , 4 , .

()

. VB , . VB , , .

, , , . , (TreeView1).


: :

Sub (ByVal As TreeNode)

, TreeView TreeNode. ..

. , , , . , .

15.      

, 2 .

16.      

, 2 , ˻.

17.      

, 1 2.

18.      

Ի, - . : .



, . . . , :

, , .

, , .

, .



(Solution)


VB , , - . VS (Solution). . . , (. 21.9), ( Solution Explorer ) ( ), . , Solution Explorer: .

, , , : (WindowsApplication1.vbproj) (WindowsApplication1.sln). 1.3.6.

, , , File Open Project ( ), , . File Add Project( ). , , (New Project)

(Existing Project). .

Solution Explorer (. 21.10).

. 21.10

, Start ? , . , , Solution Explorer , Set as StartUp Project. ( ), Remove.

. , , .

, , , . . - . , , , , .

. , .

, , , Visual Studio .NET, .




. DrawRectangles( DrawRectangle!) . :

Dim As Graphics = Me.CreateGraphics

Dim _() As Rectangle = {New Rectangle(10, 50, 30, 40), _

New Rectangle(100, 10, 60, 20), _

New Rectangle(20, 20, 120, 50)}

.DrawRectangles(Pens.Black, _)

(. 17.2).

. 17.2

FillRectangles :

.FillRectangles (Brushes.OrangeRed, _)



Web-


HTML- Web-. , Web- - . , - . . .

Web-. " ". VB ( 138). . 1 . . . "" "". , 138, .

VB. Web-, VB. :

cmdTry ""

txtNumber ,

txtMessage "", "" " "

txtNumberTry

:

Dim A As Long ' -

Dim SecretNumber As Long '

' :

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Randomize()

SecretNumber = Math.Round(1000000000 * Rnd()) '

txtNumber.Text

= 0 '

txtMessage.Text = " " '

txtNumberTry.Text = 0 '


End Sub

' :

Private Sub cmdTry_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdTry.Click

A = Val(txtNumber.Text) '

If A > SecretNumber Then ' If

txtMessage.Text

= ""

ElseIf A < SecretNumber Then

txtMessage.Text = ""

Else

txtMessage.Text = " "

End If

txtNumberTry.Text = Val(txtNumberTry.Text) + 1

End Sub

. , Web-.

Web-. , , . 23.4.



. 23.4

VBScript. HTML- . . VB, VBScript. VB. HTML- VB . , VBScript VS. , , VS . , , Internet Explorer. , , Internet Explorer Windows. , Windows .

Internet Explorer HTML- , , VB Start. Internet Explorer. .



, Internet Explorer.

HTML- :

<html>

<body bgcolor="#FFDFFF">

<h1> " "</h1>

<img src=".jpg"><p>

堠 <input type="text" size="20" name="txtNumber">

1 ""<p>

<input type="button" name="cmdTry" value=""><p>

- <input type="text" size="30" name="txtMessage"><p>

- <input type="text" size="10" name="txtNumberTry" ><p>

<i> 30 - </i>

<script language="VBScript"><!-- '

dim A ' -

dim SecretNumber '

Randomize

SecretNumber = Round (1000000000 * Rnd)

' :

txtNumber.Value=0

txtMessage.Value = " "

txtNumberTry.Value=0

' :

Sub cmdTry_OnClick()

A = int(txtNumber.Value) '

if A>SecretNumber then

txtMessage.Value = ""

elseif A<SecretNumber then

txtMessage.Value = ""

else

txtMessage.Value = " "

end if

txtNumberTry.Value= txtNumberTry.Value + 1

End Sub

--></script>

</html>

:

<script language="VBScript"><!--





--></script>

VB. . , VB. , Dim. Object. Text Value. Click OnClick. Val Int.

, :

cmdTry ""

txtNumber ,

txtMessage "", "" " "

txtNumberTry

, VB ? , HTML. VBScript , , .

HTML- . :

堠 <input type="text" size="20" name="txtNumber">

1 ""<p>

, Web- .

<input type="text" size="20" name="txtNumber">

Web- . , , , , , 堠 input type="text", 20 젠 size="20", name="txtNumber".

, HTML-

<input type="button" name="cmdTry" value=""><p>

Web- ( input type="button"). 젠 value="".

.


(NumericUpDown)


. , . 18.14.

. 18.14

: NumericUpDown1 NumericUpDown2. , .

:

Numeric

UpDown1

Numeric

UpDown2

Minimum

0

0

Maximum

100

1000

DecimalPlaces

0

2

Increment

1

0,01

. , . , Enter.

NumericUpDown.Value Decimal. ValueChanged.

, :

7.

, NumericUpDown .




. . , .

, , .

, , CD-R, CD-RW, -. , , CD-ROM DVD-ROM, , .

, , , , . - , , .

4 .

1. .

. .

, , , . .

, , , , . , . , .


2. -(CD-ROM) DVD-ROM. , . .

, , , ( 700 CD-ROM 5-10 DVD-ROM). , , , . , , .

3. - (CD-R) (CD-RW). - (CD-R) (CD-RW) . () . , , -, - , .

DVD- , 2005 .

, 2 3, , .

4. -. . . . . . . - , .



. . , , , , , . , , , -, . , .

, (. . 1).

. 1

, . : ( ), ( ), , () -. , , , ..

. , - . , , , .

, , .



(Char) Char


Char. , , .

, 1. :

Dim s As String = ""

Dim c As Char = ""

.

Char. System Char, . 14.3.1. :

Dim As Char = ""

Debug.WriteLine(" 렠 " & )

Debug.WriteLine(" ? " & Char.IsDigit())

Debug.WriteLine(" ? " & Char.IsLetter())

Debug.WriteLine(" , ? " & Char.IsLetterOrDigit())

Debug.WriteLine(" ? " & Char.IsLower())

Debug.WriteLine(" ? " & Char.IsUpper())

Debug.WriteLine(" ? " & Char.IsPunctuation())

Debug.WriteLine(" ? " & Char.IsSeparator())

Debug.WriteLine(" " & Char.ToLower())

Debug.WriteLine(" " & Char.ToUpper())

:

? False


? True

, ? True

? False

? True

? False

? False





Unicode . Char 2 , Windows 65536 . Unicode. 0 65535. Unicode AscW Strings. ChrW :







AscW ("")

1064

1064

ChrW (1064)



1064

, 0- 1200-, 64 :

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

Dim As Long

Dim As Char

For = 0 To 1200

= ChrW()

Debug.Write()

If Mod 64 = 0 Then Debug.WriteLine("")

Next

End Sub

, :

!"#$%&'()*+,-./0123456789:;<=>?@

ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz

{|}~¡¢£¥¨ª­¯²³´¸¹º¼½¾¿À

ÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿA



????????????????????????????????????????????????????????????????

????????????????????????????????????????????????????????????????

?

?

, , , . . 1200- , , , , :

? ? ? ? ? ?????????? ? ? ? ? ? ? ? ? ? ?

???????????????????? ?????????????????????????????????

?OO0???+?>?????????????????????????????

?????????????????????????????????????????

????????????? ??????dd????

ASCII . Char 1 , 256. ASCII-. , 128 255 . - ASCII-. . ASCII- Asc Strings. Chr :







Asc ("")

219

219

Chr (219)



219

, 32- 255-:

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click

Dim As Long

For = 32 To 255

Debug.Write(Chr())

Next

End Sub

:

!"#$%&'()*+,-./0123456789:;<=>?@

ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz

{|}~ ­



, () , Unicode .


VB


VB. , | , , VB. [] , , , , , .

, (, ), .

:

Public | Private | Protected | Friend | Protected Friend

:

[ | Static ] [ Shared ] [ Shadows ] [ ReadOnly ]

[ Dim ] [ WithEvents ] [ ( ) ]

[ As [ New ] ] [ = ]

:

[ ] [ Shadows ] Const

[ As ] =

, , , . . , , , .

:

[ Overloads | Overrides | Overridable | NotOverridable | MustOverride | Shadows | Shared ] [  ] Sub

[ ( ) ]

End Sub

:

[ Overloads | Overrides | Overridable | NotOverridable | MustOverride | Shadows | Shared ] [  ] Function [ ( ) ] [ As ]

End Function

:

[  ] [ ReadOnly | WriteOnly ] [ Overloads | Overrides | Overridable | NotOverridable | MustOverride | Shadows | Shared ] Property


[ As ]

[ Get



End Get ]

[ Set ( ByVal As )



End Set ]

End Property

:

[ ] [ Shadows ] Event

:

[ ] [ Shadows ] Enum

[ =

]

[ =

]

. . . . . . . .

End Enum

:

[ ] [ Shadows ] Structure



End Structure

:

[   ] [ Shadows ] [ MustInherit | NotInheritable ] Class  [ Inherits   ]



End Class

:

[ Public | Friend ] Module



End Module



, , , , .




.NET Framework, . , , . , ( ) , .NET Framework? , .




22.14.1 . . , :

, , , ..

Toolbox .

-, . .




, Web- . Toolbox Microsoft WebBrowser. . AxWebBrowser1. . :

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

AxWebBrowser1.Navigate("http://www.yahoo.com/")

End Sub

Navigate AxWebBrowser1. , VB . -.

, , (. . 23.2).

. 23.2

, .

, , , . , , , VB. AxWebBrowser1, :

Busy. True, .

DocumentComplete. , .

Stop. , Web-.

, Internet Explorer , , .

, VB (E-mail), Internet Explorer, , ..

19.      

-. , .



,


, (6.1.2) (15.8). . , .

. .




, , VB . . ? , , , . , , , . ,

Me.BackColor = Color.Aquamarine

.




, , , .

: .txt - , , 10. , , . . , . , 10, , .

:

1.       , .

2.       , , . .

. 1 .

:

', :

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim As New System.IO.StreamReader("E:\VB\.txt")

= .ReadLine ' ,

.Close()

End Sub

' ,

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

Debug.WriteLine() '

= + 1 '

End Sub

', :

Private Sub Form1_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed

Dim As New System.IO.StreamWriter("E:\VB\.txt")


.WriteLine() ' ,

.Close()

End Sub

Closed. .

- . . . , , . , , , , . - . , , , , - , , . . , , , --. , .

13.      

. 1 . . . , , , . , . , . , , , , .


(Index)


. : . , , . HTML-, . HTML-, , , HTML- .

. HTML Help Workshop Index. , ( ). Index.hhk. , .

Index (Insert a keyword) , . , Keyword . , HTML- , Add. . Browse, HTML- .htm. , Add.

. . 26.7 Index.

. 26.7

(Sort keywords alphabetically), ( ).

(Search) ( ), .




Microsoft RTF, HTML. Visual Studio .NET HTML Help Workshop. VS 4.1, Windows. . , . 26.3, .

File New. (. 26.2), , .

. 26.2

. . , . Project. .

, , , RTF HTML. , , , Next.

Browse . , , , Help , . , . (, .hhp). .

, . , Next.

Finish. . . HTML Help Workshop (. 26.3).

. 26.3




, , . . , , .

. VB , , . (field) , Public Friend:

Public C As Integer = 10

(Properties) Property , 22.5. .

, . .

, . . .

. - . ( ). .

, , , (, ), , (, ).

. 5 3 . :

5 , :

TextBox1

TextBox2

TextBox3

TextBox4

TextBox5 1

1 1, ( ).


Private Sub _()

= 2 * ( + )

End Sub

Private Function _() As Integer

_()

Return * _

End Function

Public Function ___() As Integer

Return ____ * _()

End Function

End Class

: , . , , . , :

Dim 1 As New

( ):

Dim 1, 2 As

:

1 = New ꠠ '

. 5 , Public. , . , . Public ( ) . , -. ! ? , . .

. , , . , . .

, , . , . 1 , .



_ . Private, , . - , Private Public. Private , . .

_ . Private .

___ , ( Button3_Click, ), Public. , .

? , , , , , , , , , . , , .

. , , , , , .

, . , , . , , , , , , .



. . . 1. , . 2 , 200 .

:

:

Dim (100) As

Dim k As Integer = 1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

(k) = New

(k)._ = k

(k). = TextBox1.Text

(k). = TextBox2.Text

(k). = TextBox3.Text

(k)._ = TextBox4.Text

(k).____ = TextBox5.Text

k = k + 1

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

Dim i As Integer

For i = 1 To k - 1 ' ⠠ k-1

If (i)._ > 200 Then Debug.WriteLine((i).)

Next

End Sub

:

Public Class

Public _ As Integer

Public As String

Public , As Integer

Public _ As Integer

Public ____ As Integer

Private As Integer

Private Sub _()

= 2 * ( + )

End Sub

Private Function _() As Integer

_()

Return * _

End Function

Public Function _() As Integer

Return ____ * _()

End Function

End Class

: (1 2) 101 :

Dim (100) As

100 , .

1 k

k = k + 1

(k) = New

.

_. , , , , (8), , 8. , : , , ?!




. , ! . . . , .NET Framework. . , , .

6.1.

.NET Framework : . , , , . Math System. , , , ( ), . Pen. Pen, Pen:

Dim As New Pen(Color.Red, 20) '

, . .

. . : Project Add New Item Add New Item (. 21.1) Class Open. , Solution Explorer Class1.vb, Class1.vb, :

Public Class Class1

End Class

, .

( , ) :


Public Class

Public

C1 As Integer = 2281

Public

Sub ()

Debug.WriteLine(2004)

End Sub

End Class

C1 Dim

Public
. , C1 , . . , , , , . , , , . , , , . .

. :

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim As New

Debug.WriteLine(.C1)

.()

End Sub

, , :

2281

2004

. New. . ( ) .

, , , C1, .



___.dll. Windows Control Library, ___. . _, . Project Add New Item Add New Item (. 25.5) User Control _ Open. , Solution Explorer _.vb _.vb.

. 25.5

Inherits System.Windows.Forms.UserControl

UserControl, . , :

Inherits Button

. . , (. 25.6).

. 25.6

, . ( - , .)

, 22.14.1 New, . , (Image) , . Text .

:

Public Class _

Inherits Button

Windows Form Designer generated code

End Class

, 22.14.1:

Public Class _

Inherits Button

Windows Form Designer generated code

Public ReadOnly Property _() As Integer

Get

Return ___

End Get

End Property

Private ___ As Integer = 0


Public ReadOnly Property () As Boolean

Get

Return _

End Get

End Property

Private _ As Boolean = False

Public Event _()

Private Sub __Click( ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Click

___ = ___ + 1

Me.Text = ___ & " ."

If ___ = 10 Then

RaiseEvent _()

_ = True

End If

End Sub

Public Sub (ByVal As Integer)

Me.Left = Me.Left +

End Sub

End Class

, , .

. New, , Windows Form Designer generated code. , 6.1.3. :

Public Sub New()

MyBase.New()

'This call is required by the Windows Form Designer.

InitializeComponent()

'Add any initialization after the InitializeComponent() call

J

End Sub

, , .


ListView ,


ListView (. . 20.11).

. 20.11

, . , ListBox, , .

. ListView. ListView1. LV.

View Details. .

CheckBoxes True. .

, , ImageList . ListView, SmallImageList ListView.

GridLines True. . , . .

. Columns, , . Columns. ( . 20.12 ). .

. 20.12

. (20.6). Add, ListView . Members Columns. . . Remove . , (Name) (Text), . 20.11.

. 20.13.

. 20.13

. ListView ListViewItem. - Items ListView. Items ListView. ( . 20.14 ). .




. 20.14

(20.6). Add, ListView . Members Columns. . Remove . . . Text ImageIndex ( StateImageIndex ).

ListView .

. 4 ListViewItem. . , . . . . . SubItems. SubItems ( . 20.15 ). , .



. 20.15

. Add Text, ListView, , .

4 , . , . 20.11.

ListViewItem SubItems. 4 , 4 . , SubItems. Items SubItems. , Items , SubItems .



cls.

. . , : , . , , , . , - , , , , . ? , .

. pict. pict(10) . - , . . , . , .

pict .

. :

:

Module Module1

Public As Form1

Public As cls ' cls

Public Const _ As Integer = 20

End Module

:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

= Me

= New cls ' cls

_()

End Sub

Private Sub _()

_.Text = 0 '

._() '


End Sub

cls:

Public Class cls

Private x As Integer '

Private y As Integer

Public Sub New()

.pict.Width = _

.pict.Height = _

End Sub

Public Sub _() '

' :

x = ..Left + ..Width * 1 / 4

y = ..Top + ..Height / 2 '

____()

End Sub

Private Sub ____()

.pict.Left = x

.pict.Top = y

End Sub

End Class

. , .

.

, .

Form1_Load. ,

= Me

(. 21.2).

cls . New . pict _. (), (), pict.

_, , , . , . , . , _ _ . , - , .

____, . , , . . , ..Left . , .

, .



, . , , , . 17.7. , , , , . , , .

. 17.7

, :

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim As Graphics = Me.CreateGraphics

Dim As New Drawing2D.GraphicsPath

.AddArc(20, 30, 120, 120, 0, 330)

.AddArc(220, 30, 10, 10, 270, 180)

.CloseFigure()

.AddEllipse(90, 50, 30, 30)

Me.Region = New Region()

End Sub

: . , . Region, , . . . Region( Region). , . ( ) . , , . Region Region, . , .


, .

. , , . . . .

. , , ! , . . , , . , . - .

? , , ! , . , - , :

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

Me.Close()

End Sub

.


-


. 1 , 2 . , -, , , . - , , .

:

:

Module Module1

Public 1 As New Form2

Public 2 As New Form2

End Module

1:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

1.Show()

2.Show()

End Sub

2:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Me.BackColor = Color.Blue

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

Me.BackColor = Color.Red

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

1.Text = "1"

1.BackColor = Color.Black

2.Text = "2"

2.BackColor = Color.White

End Sub

, 1, - . Form2. , . , . Me. .

, , .




, . . :

:

Module Module1

Public 1 As New

Public 2 As New

End Module

:

Public Class

Public C As Integer = 10

Public Sub ()

1.C = 101

2.C = 102

End Sub

End Class

:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Debug.WriteLine(1.C)

Debug.WriteLine(2.C)

1.C = 1

2.C = 2

Debug.WriteLine(1.C)

Debug.WriteLine(2.C)

1.()

Debug.WriteLine(1.C)

Debug.WriteLine(2.C)

End Sub

, , :

10

10

1

2

101

102

, : 1 2. , . ? , . , , . C.

C 10, , , Button1_Click.

. C , , .

, . , . , , , -.



(Contents)


HTML Help Workshop Contents. (. 26.5), ( ).

. 26.5

Table of Contents.hhc. , .

. 26.6 . , Contents HTML Help Workshop. .

. 26.6

(Insert a page ) , . ( ). . , HTML- , Add. ( ). Browse, HTML- .htm.

, , HTML Help Workshop.

. (Insert a heading ), No . HTML-, .

. () , 4 , .



OleDbConnection, OleDbDataAdapter DataSet


. ADO.NET : OleDbConnection (), OleDbDataAdapter () DataSet. .

? - . . . OleDbConnection. , .

ADO.NET , . , - , . , , , , , . . , , - . , , , .

DataSet. , . DataSet OleDbDataAdapter. Fill DataSet, Update DataSet .

, , , DataSet, , , .


OleDbConnection OleDbDataAdapter. , - ( ) . , .

. VS Server Explorer, 24.4.1. ? Server Explorer . VB (password). Don't include password. , : OleDbConnection1 OleDbDataAdapter1 ( . 24.23).

! , OleDbDataAdapter . - , , .

. , , . Preview Data. Data Adapter Preview, Fill Dataset. . 24.21.



. 24.21

. . , - . . , .

, .

DataSet. DataSet. Generate Dataset. (. 24.22). DataSet1, , OleDbDataAdapter1.



. 24.22

. , DataSet11 ( . 24.23). , , .

, , . , - , , DataSet . . , Access (. 24.3) Server Explorer (. 24.16). . DataGrid. Toolbox ( . 24.23 . 24.24). DataSet, .



DataGrid. , , DataGrid, , . DataSource( ) DataSet11. (. . 24.23). DataGrid DataSet11. , DataGrid, DataSet11.

DataGrid . Caption , , Caption.



. 24.23

, , , . Fill DataSet. , , , . DataSet Update.

:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

OleDbDataAdapter1.Fill(DataSet11)

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

OleDbDataAdapter1.Update(DataSet11)

End Sub

. . (. 24.24).



. 24.24

, . , Access Server Explorer.

, Delete. .

, .



.

, Windows Application ( Windows), Class Library( ) . . 25.1. - , , . , Class1. , , _ :

Public Class _

Public Shared Sub 1()

MsgBox(1)

End Sub

Public Sub 2()

MsgBox(2)

End Sub

End Class

Public Module _

Public C As String

Public Function (ByVal A As Integer, ByVal B As Integer) As Integer

Return A + B

End Function

End Module

. , , , , , , , , , , .

. . , . , , , . , , , - . , , .

. Build Build Solution, VB BIN .dll. , , , 4.2.4. .

, , Object Browser. , .NET Framework. , _ _, , .

, .




__. 10. 1, 0, .

. , , . :

.

:

, , , 1 .

, , , .

, , , .

.

.

, , cls. , , _ cls.

, :

(1), (2), (10) , () .

, .

, :

10 . , 0.

.

.

. . cls . , : cls.

: .


:

Private Const _ As Integer = 10

Private (_) As cls ' cls

Public pict(_) As PictureBox '

Public __ As Integer



Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

= Me

KeyPreview = True '

_.ReadOnly = True

Randomize() '

' -:

= New cls

Dim i As Integer

For i = 1 To _

(i) = New cls

Next i

_()

Timer1.Enabled = False ' " "

End Sub

Private Sub __Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _

Handles _.Click

_()

Timer1.Enabled = True ' ,

End Sub

Private Sub _()

_.Text = 0 '

__ = _

__.Text = _

_.Focus()

._() '

Dim i As Integer

For i = 1 To _

(i)._() '

Next i

End Sub

' , :

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

.() '



Dim i As Integer

For i = 1 To _

(i).() '

Next i

' , 1:

_.Text = _.Text + 1

If __ = 0 Then Timer1.Enabled = False '

End Sub

Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) _

Handles MyBase.KeyDown

.__(e)

End Sub

cls .

cls:

Public Class cls

Private _ As Integer

Private Shared __ As Integer = 0

Private Const _ As Double = 12

Private x, y As Double '

Private dx, dy As Double '

Public Sub New()

__ = __ + 1

_ = __

' - :

.pict(_) = New PictureBox

' :

.pict(_).Width = _

.pict(_).Height = _

.pict(_).SizeMode = PictureBoxSizeMode.StretchImage

' PictureBox :

.pict(_).BackColor = Color.White

.pict(_).Image = Image.FromFile("MOON06.ICO")

.Controls.Add(.pict(_)) '

.pict(_).BringToFront() '

End Sub

Public Sub _()

Const _ As Double = 1.8 '



' :

x = ..Left + ..Width * 3 / 4

y = ..Top + ..Height / 2

____()

' :

dx = _ * (1 - 2 * Rnd()) ' _

dy = _ * (1 - 2 * Rnd()) ' _

End Sub

Private Sub ____()

.pict(_).Left = x

.pict(_).Top = y

End Sub

Public Sub () ' ,

If () Then ___() ' , ,

() ', ,

() ', ,

____()

End Sub

Private Sub ()

x = x + dx

y = y + dy

End Sub

Private Sub () '

If ___() Then dy = -dy '

If ___() Then dx = -dx '

End Sub

Private Function ___() As Boolean

If y < ..Top Or y + _ > ..Top + ..Height Then

Return True

Else

Return False

End If

End Function

Private Function ___() As Boolean

If x < ..Left Or x + _ > ..Left + ..Width Then

Return True

Else

Return False



End If

End Function

Private Function () As Boolean

Const As Double = 10 ' ,

'

' , :

If Math.Abs(x - .X - ((_ - _) / 2)) < _

And Math.Abs(y - .Y - ((_ - _) / 2)) < Then

Return True

Else

Return False

End If

End Function

Private Sub ___()

x = -10000 : y = -10000 '

dx = 0 : dy = 0 '

.__ = .__ - 1

.__.Text = .__

End Sub

End Class

. , . , , , , .

. , . , . .

. , PictureBox. cls, :

Public pict(_) As PictureBox '

:

Timer1.Enabled = True

,

Timer1.Enabled = False

.



, , . . , .

. . , , .

. _ .

, . , , . . dx dy x y, . , .

, . __Click VB _ . dx dy. Rnd 0 1, , dx, dy -1.8 1.8. , . , _.

x y .

___ ___ __.

. , , , , dy = -dy, . ! , dx = -dx . , _ = 30 _ = 1 , . dx dy, x y.



. , , . , 22.6. __, 1 , _ .

, PictureBox . 15.8. . , , .

.pict(_).SizeMode = PictureBoxSizeMode.StretchImage

, PictureBox PictureBox.

. , . . , . Private. _ . , .

. . . . , , .

. , , 100 1000. . ? (. 13.2).

, , , , , , .



, .NET Framework , , . , ? , . ? , . .

. , . . :

1. ( ),

2. .

. , Button1_Click Form1_BackColorChanged:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Me.BackColor = Color.Aquamarine

End Sub

Private Sub Form1_BackColorChanged(ByVal sender As Object, ByVal e As System.EventArgs) _

Handles MyBase.BackColorChanged

MsgBox(" ")

End Sub

. , , , .

.

3. (, Windows . 22.15).

, . , : . , .

, , .




, - SQL-, DataSet. . , SQL-, , . , , , , .

:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim As New OleDb.OleDbConnection _

("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\\.mdb")

.Open()

Dim As New OleDb.OleDbCommand(TextBox1.Text, )

.ExecuteNonQuery()

.Close()

End Sub

: OleDbConnection. (Provider) (Data Source) , . , . , :

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\.mdb

. .

24.5.7. . (TextBox1.Text) , . .

.

, , .


, SQL- ( SELECT) , .

SQL- Access , , .

, , - , . 24.32 , . SQL- . , : OleDbConnection1, , , . , . , OleDbConnection1, -:

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

OleDbConnection1.Open()

Dim As New OleDb.OleDbCommand(TextBox1.Text, OleDbConnection1)

.ExecuteNonQuery()

OleDbConnection1.Close()

End Sub

. VB . . , , . : ( ) . . . , .

. (. ).

. , , , .



. 4. RTF, HTML.

File New. (. 26.2), HTML File. HTML- (. 26.4) (HTML Title). . HTML- <Title> </Title>.

. 26.4

HTML- . . <BODY> </BODY> . , . 26.1. , HTML 23. :

<BODY>

<H1> </H1>

, .

</BODY>

File Save File, .htm.

3 , File New File Save File.



TreeView ,


. TreeView. TreeView1. TV. Nodes( ) TreeView. ( . 20.17 ). .

. 20.17

. . , .

. , , , . , , .

. . . , , : . . . . . , .

, . TreeView ListView ImageList . : (SelectedImage) , .



, , ,


VB , Windows, : , , . File System.IO. Directory System.IO.

c: temp 222, 333, 666, 999 1.txt 2.txt.

. , StreamWriter, :

Dim As New System.IO.StreamWriter("E:\VB\Filimon.txt")

.

File:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

' 1.txt temp c: 222 temp c:

File.Copy("c:\temp\1.txt", "c:\temp\222\1.txt")

' 1.txt , 222:

File.Copy("c:\temp\1.txt", "c:\temp\222\1.txt", True)

' 1.txt 3.txt temp c: 222 temp c:

File.Copy("c:\temp\1.txt", "c:\temp\222\3.txt")

' 1.txt 4.txt temp c: :

File.Copy("c:\temp\1.txt", "c:\temp\4.txt", True)

' 1.txt temp c: 333 temp c:

File.Move("c:\temp\1.txt", "c:\temp\333\1.txt")

' 3.txt 5.txt 222 temp c: temp c:

File.Move("c:\temp\222\3.txt", "c:\temp\5.txt")

' 4.txt temp c: 6.txt:

File.Move("c:\temp\4.txt", "c:\temp\6.txt")


' 5.txt temp c:

File.Delete("c:\temp\5.txt")

' 6.txt temp c:, .....

If File.Exists("c:\temp\6.txt") Then Debug.WriteLine(" ") _

Else Debug.WriteLine(" ")

End Sub

.

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

' 6.txt temp c: (Hidden):

File.SetAttributes("c:\temp\6.txt", FileAttributes.Hidden)

' 6.txt temp c:

Debug.WriteLine(File.GetAttributes("c:\temp\6.txt"))

' 6.txt temp c:

Debug.WriteLine(File.GetCreationTime("c:\temp\6.txt"))

' 6.txt temp c:

Debug.WriteLine(File.GetLastAccessTime("c:\temp\6.txt"))

' 6.txt temp c:

File.SetLastWriteTime("c:\temp\6.txt", #11/21/2004 10:42:00 PM#)

' 6.txt temp c:

Debug.WriteLine(File.GetLastWriteTime("c:\temp\6.txt"))

End Sub

: SetAttributes

(, ), GetAttributes .

. Directory:

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

' temp c: 444:

Directory.CreateDirectory("c:\temp\444")

' temp c: 444, :

Directory.Delete("c:\temp\444")



' 222 temp c:, .....

If Directory.Exists("c:\temp\222") Then Debug.WriteLine(" ") _

Else Debug.WriteLine(" ")

' 666 temp c: 222 temp c:

Directory.Move("c:\temp\666", "c:\temp\222\666")

' 666 777 222 temp c: temp c:

Directory.Move("c:\temp\222\666", "c:\temp\777")

' 777 555:

Directory.Move("c:\temp\777", "c:\temp\555")

End Sub

: Move . . , , .

.

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

' 333 temp c:

Directory.SetLastAccessTime("c:\temp\333", #3/28/2003 10:22:00 AM#)

' 333 temp c:

Debug.WriteLine(Directory.GetLastAccessTime("c:\temp\333"))

' 333:

Debug.WriteLine(Directory.GetCreationTime("c:\temp\333"))

' 333 temp c:

Debug.WriteLine(Directory.GetLastWriteTime("c:\temp"))

', 333:

Debug.WriteLine(Directory.GetParent("c:\temp\333"))

End Sub



.

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click



' ( ):

Debug.WriteLine(Directory.GetCurrentDirectory)

' 999 temp c:

Environment.CurrentDirectory

= "c:\temp\999"

' 999:

File.Copy("44.txt", "55.txt")

End Sub

: . . . , , : .

CurrentDirectory Environment System.

, , BIN .

:

', temp c:

Dim () As String = Directory.GetDirectories("c:\temp")

Dim As String

For Each In

Debug.WriteLine()

Next

', temp c:

Dim () As String = Directory.GetFiles("c:\temp")

Dim As String

For Each In

Debug.WriteLine()

Next

', :

Dim () As String = Directory.GetLogicalDrives

Dim As String

For Each In

Debug.WriteLine()

Next

: , , . GetDirectories , GetFiles , GetLogicalDrives . , For Each.



Toolbox _, . , , !. .

. , , , Windows, Windows Application ( Windows). Windows, (Control), Windows Control Library ( Windows) . . 25.1.

. 25.1

___ . (. 25.2). , . , , UserControl . , , , (User Control Designer).

. 25.2

User Control, , Toolbox. !. . , . 25.4.

. :

Public Class UserControl1

Inherits System.Windows.Forms.UserControl

Windows Form Designer generated code

End Class

, UserControl1, System.Windows.Forms.UserControl. (, ), : , ..

UserControl1 _.

. , MouseEnter, , . . _ Events, MouseEnter. . :



VB


VB . , Access, . , VB .

. Solution Explorer References (Add Reference) (25.2.2). COM Add Reference Microsoft ADO Ext. 2.7 for DDL and Security, Select OK. ADOX, Catalog Create. :

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim As ADOX.Catalog = New ADOX.Catalog

.Create _

("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\.mdb;Jet OLEDB:Engine Type=5")

End Sub

(24.5.9). . C:\\.mdb. .

, . . , , . .



VB


VB 24.5.8. , , Access. Access , .

. bin , . :

Public As New OleDb.OleDbConnection _

("Provider=Microsoft.Jet.OLEDB.4.0;Data Source =.mdb")

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

.Open()

Dim As New OleDb.OleDbCommand ("CREATE TABLE ( COUNTER CONSTRAINT

PRIMARY KEY,Avtor STRING,Nazvanie STRING, Data DATETIME, Kol_str INTEGER)", )

.ExecuteNonQuery()

.Close()

End Sub

, , . , , . .mdb.

.

Dim. , . , , . , . , , : Edit Advanced Word Wrap.

.

, .

. . . .



Access


. Microsoft Access

.mdb.

. (. 24.1), .

. 24.1

. , (. 24.2).

. 24.2

. , VB, , . .

. Access . . . ( ). . . ( . 24.4).

. (. 24.3). ( ) ().

. 24.3

, Access .

. Access (. 24.4).

. 24.4

- ,

. . , . . , .


.
, (. 24.2). . , , , . , , .

. , , : , . , , , . . , ? , , , , . Access , , .

, . . . .

, , . . , , , . .

, , . , Access . , . , , , Access, . , . . : ?

, .


VB


VB. . VB : .



Web- VB


Windows VS 4.1, Web-, VBScript. VB! , . , , .

VB , VB , Web-(WebApplication).

VS. : File New Project. , , , Windows, Windows Application ( Windows). Windows, Web-, ASP.NET Web Application (. 23.7).

. 23.7

. (. 23.8).

. 23.8

Windows. , Web- , Web-. Toolbox , , . , , . , , . , . , .

Web- , . - . , Size, Font.

Solution Explorer Web- WebForm1.aspx , , .aspx (. 23.9).


. 23.9

. , . 23.10.



. 23.10

Page_Load Form_Load Windows. . - , :

Button1.BackColor = Color.Yellow

. , Internet Explorer Web-. , . .

. , , , :

Label1.Text = "!"

. .

, VB Web-. . , Windows, .

Page_Load:

Imports System.IO

Public Class WebForm1

Inherits System.Web.UI.Page

Web Form Designer generated code

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Button1.BackColor = Color.Yellow

Dim As String = "C:\INFORMAT.TXT"

Dim As Integer

If Not File.Exists() Then

Dim As New StreamWriter()

.WriteLine(0)

.Close()

End If

Dim As New StreamReader()

= .ReadLine

.Close()

If = 0 Then

Label2.Text = " "

Else

Label2.Text = " " & & " ."

End If

= + 1

Dim 1 As New StreamWriter()

1.WriteLine()

1.Close()

End Sub

End Class

: If , , , 0. . If 2.

= + 1

, .

. .

Web-, Web- Visual Basic .NET, , . , , HTML XML. .


Web-


Web- " ". . Internet Explorer , . 23.3.

. 23.3

VB . Notepad ( Windows). :

<html>

<body bgcolor="#FFDFFF">

<h1> " "</h1>

<img src=".jpg"><p>

<i> 30 - </i>

</html>

:

Web-, HTML.

HTML <html> </html>.

ࠠ <body bgcolor="#FFDFFF"> ( 16- ( A F. 6 )). , .

<h1> , . <h2> . , , . , , .

ࠠ <img src=".jpg"><p> (img), (src) .jpg, , HTML-. <p> Web-.

<i> , , .


HTML- Web-. HTML- htm html. , Web- , , . , File Open. , , , , , Web-.

, Web- HTML-. Web- ( ) Microsoft Word FrontPage, , , VB . HTML- . , , , . Internet Explorer, HTML- View Source. Web-.

HTML. . - :

<html>

<h1> " "</h1>

</html>

htm html. HTML-. , . HTML- , , (Refresh). HTML-. HTML- .

, , , , . , . .


(ListBox, ComboBox, CheckedListBox)


. Toolbox : ListBox, ComboBox, CheckedListBox. , - .




1.       ., ., Visual Basic .NET, , . , 2003.

. , , .

2.       , Visual Basic .NET 24 , , 2002.

, .

3.       , . Visual Basic .NET. , . , 2002.

. .

4.       Visual Basic .NET, , . -, 2002.

.

5.       .. Visual Basic. , , -, 2003.

Visual Basic 6.0. .

6.       .. " : Visual Basic 5", , -, 1998.

7.       , " Visual Basic 6", "", 1999.




, , . , , . DrawCurve , . , , (tension). , , , . 17.5. , . , 0,5.

4 - 5 :

Dim As Graphics = Me.CreateGraphics

Dim _() As Point = {New Point(50, 20), New Point(70, 10), New Point(30, 100), _

New Point(70, 100), New Point(80, 80)}

.DrawCurve(Pens.Black, _, 0)

.TranslateTransform(100, 0) '

.DrawCurve(Pens.Black, _, 0.3)

.TranslateTransform(100, 0) '

.DrawCurve(Pens.Black, _, 0.5)

.TranslateTransform(100, 0) '

.DrawCurve(Pens.Black, _, 0.8)

(. 17.5).

. 17.5

: , .

, . , .

, , .

DrawPolygon DrawClosedCurve .

FillPolygon FillClosedCurve .



Splitter


Windows - . Splitter.




- ____. , . . - - . ? , , - . , . , . .

, , :

Public Shared ____ As Integer

Shared . .

:

.____ = TextBox5.Text

Debug.WriteLine(.____)

, , . , . , - , -:

(k).____ = TextBox5.Text

Debug.WriteLine((i).____)

. ____, .

, . Shared:

Public Shared Function () As Integer

. Math System. , .

, Private. .

, , , , .

: , ? , , . : .