. , , ,

,,,

10 : Visual Basic — ,

 

1

1

Len (String)-

String

Left (String,Length)-

Length String

Right (String,Length)-

Length String

Mid (String, Start[,Length] )-

Length String ,

Start

Trim(String)- -

String

Ltrim(String)-

String

Rtrim(String)-

String

InStr ([Start,] String, String1[,Comp] )--

String1 String

2

Sub ( )

Dim S As String, Num As String

Dim nNum As Integer, i As Long

S = InputBox(" ")

Num = "0123456789"

nNum = 0

For i = 1 To Len(S)

If (InStr(Num, Mid(S, i, 1))) > 0 Then

nNum = nNum + 1

End If

Next i

MsgBox ("- =" + Str(nNum))

End Sub

3

Sub Swap(S As String, i As Long, j As Long)

Dim C As String

C = Mid(S, i, 1)

Mid(S, i, 1) = Mid(S, j, 1)

Mid(S, j, 1) = C

End Sub

Sub ( )

Dim S As String, Sogl As String

Dim S1 As String, c As String

Dim Gl As String, K As Long

Dim i As Long

Sogl = ""

S = InputBox(" ")

Gl = ""

For i = 1 To Len(S)

c = Mid(S, i, 1)

S1 = S1 + c

If InStr(Gl, c) > 0 Then

K = K + 1

If K > Len(Sogl) Then K = 1

S1 = S1 + Mid(Sogl, K, 1)

End If

Next i

For i = 1 To Len(S1) - 4 Step 5

Call Swap(S1, i, i + 4)

Call Swap(S1, i + 1, i + 3)

Next i

S = S1

MsgBox (S)

End Sub

4

Sub ()

Dim S As String, i As Long

Dim S1 As String, c As String

Dim Gl As String, K As Long

S = InputBox(" ")

Gl = ""

For i = 1 To Len(S) - 4 Step 5

Call Swap(S, i, i + 4)

Call Swap(S, i + 1, i + 3)

Next i

For i = 1 To Len(S)

c = Mid(S, i, 1)

S1 = S1 + c

If InStr(Gl, c) > 0 Then i = i + 1

Next i

MsgBox (S1)

End Sub

5

Sub ( )

Dim S As String, S1 As String

Dim n As Long, C As String

S = InputBox(" ")

n = 0

For i = 1 To Len(S)

C = Mid(S, i, 1)

If Mid(S, i, 3) = "" Then

S1 = S1 + " "

n = n + 1

i = i + 2

ElseIf Mid(S, i, 7) = "" Then

S1 = S1 + " "

i = i + 6

n = n + 1

Else

S1 = S1 + C

End If

Next i

MsgBox (S1)

MsgBox (n)

End Sub

2

1

Do While L } S

S } L-

Loop }

Do }S

S } L-

Loop While L }

Do }S

S },

[exit do] }

Loop } exit do

While L } ,

S }Do while...Loop

Wend }

Do Until L }S

S } L-

Loop }

Do }S

S } L-

Loop Until L}

for i=i0 to i step h}S

S } i0 -

[Exit for] }

Next i }ik . h

2

Sub ()

Dim S As String, En As String

Dim nEn As Integer, i As Long

S = InputBox(" ")

En = "abcdefghijklmnopqrstuvwxyz"

nEn = 0

For i = 1 To Len(S)

If (InStr(En, Mid(S, i, 1), 1)) > 0 Then

nEn = nEn + 1

End If

Next i

MsgBox ("- =" + Str(nEn))

End Sub

3

Sub Swap(S As String, i As Long, j As Long)

Dim c As String

c = Mid(S, i, 1)

Mid(S, i, 1) = Mid(S, j, 1)

Mid(S, j, 1) = c

End Sub

Sub ()

Dim S As String, Sogl As String

Dim S1 As String, c As String

Dim Gl As String, K As Long

Dim i As Long

Sogl = ""

S = InputBox(" ")

Gl = ""

For i = 1 To Len(S)

c = Mid(S, i, 1)

S1 = S1 + c

If InStr(Gl, c) > 0 Then

K = K + 1

If K > Len(Sogl) Then K = 1

S1 = S1 + Mid(Sogl, K, 1)

End If

Next i

For i = 1 To Len(S1) - 5 Step 6

Call Swap(S1, i, i + 5)

Call Swap(S1, i + 2, i + 3)

Call Swap(S1, i + 1, i + 4)

Next i

S = S1

MsgBox (S)

End Sub

4

Sub ()

Dim S As String, i As Long

Dim S1 As String, c As String

Dim Gl As String, K As Long

S = InputBox(" ")

Gl = ""

For i = 1 To Len(S) - 5 Step 6

Call Swap(S, i, i + 5)

Call Swap(S, i + 2, i + 3)

Call Swap(S, i + 1, i + 4)

Next i

For i = 1 To Len(S)

c = Mid(S, i, 1)

S1 = S1 + c

If InStr(Gl, c) > 0 Then i = i + 1

Next i

MsgBox (S1)

End Sub

5

Sub ()

Dim S As String, S1 As String

Dim n As Long, C As String

Dim Name As String

S = InputBox(" ")

Name = InputBox(" ")

n = 0

For i = 1 To Len(S)

C = Mid(S, i, 1)

If Mid(S, i, 3) = "" Then

S1 = S1 + Name

n = n + 1

i = i + 2

ElseIf Mid(S, i, 7) = "" Then

S1 = S1 + Name

i = i + 6

n = n + 1

Else

S1 = S1 + C

End If

Next i

MsgBox (S1)

MsgBox (n)

End Sub


3

1

If L then }S

S } L -

End If }

If L1 then }S1

S1 } L1 .

Elseif L2 then } , -

S2 } L2 ..

- - - - - - - - } Ln-

Elseif Ln then }

Sn }Sn+1

Else }

Sn+1 }

End if }

2

Sub ( )

Dim S As String, Rus As String

Dim nRus As Integer, i As Long

S = InputBox(" ")

Rus = ""

nRus = 0

For i = 1 To Len(S)

If (InStr(Rus, Mid(S, i, 1))) > 0 Then

nRus = nRus + 1

End If

Next i

MsgBox ("- =" + Str(nRus))

End Sub

3

Sub ()

Dim S As String, Sogl As String

Dim S1 As String, c As String

Dim Gl As String, K As Long

Dim i As Long

S = InputBox(" ")

Gl = ""

For i = 1 To Len(S)

c = Mid(S, i, 1)

S1 = S1 + c

K = K + 1

If K > Len(Gl) Then K = 1

S1 = S1 + Mid(Gl, K, 1)

Next i

For i = 1 To (Len(S1)) / 2

Call Swap(S1, i, Len(S1) - (i - 1))

Next i

S = S1

MsgBox (S)

End Sub

4

Sub ()

Dim S As String, Sogl As String

Dim S1 As String, c As String

Dim Gl As String, K As Long

Dim i As Long

S = InputBox(" ")

For i = 1 To (Len(S)) / 2

Call Swap(S, i, Len(S) - (i - 1))

Next i

For i = 1 To Len(S) Step 2

c = Mid(S, i, 1)

S1 = S1 + c

Next i

S = S1

MsgBox (S)

End Sub

5

Sub ()

Dim S As String, S1 As String

Dim n As Long, C As String

S = InputBox(" ")

n = 0

For i = 1 To Len(S)

C = Mid(S, i, 1)

If Mid(S, i, 1) = "&" Then

S1 = S1 + ""

n = n + 1

ElseIf Mid(S, i, 1) = "#" Then

S1 = S1 + ""

n = n + 1

Else

S1 = S1 + C

End If

Next i

MsgBox (S1)

MsgBox (n)

End Sub


4

1

Select Case }

Case 1 }1 -

S1 } S1, 2

Case 2 } S2 . .

S2 }

- - - - - - - - } ,

Case n } Sn+1

Sn }

Case Else }

Sn+1 }

End Select }

2

Sub ( )

Dim S As String, Rus As String

Dim nRus As Integer, i As Long

S = InputBox(" ")

Rus = ""

nRus = 0

For i = 1 To Len(S)

If (InStr(Rus, Mid(S, i, 1))) > 0 Then

nRus = nRus + 1

End If

Next i

MsgBox ("- =" + Str(nRus))

End Sub

3

Sub Swap(S As String, i As Long, j As Long)

Dim c As String

c = Mid(S, i, 1)

Mid(S, i, 1) = Mid(S, j, 1)

Mid(S, j, 1) = c

End Sub

Sub ( )

Dim S As String, Sh As String

Dim S1 As String, c As String

Dim Gl As String, K As Long

Dim i As Long

Sh = ""

S = InputBox(" ")

Gl = ""

For i = 1 To Len(S)

c = Mid(S, i, 1)

S1 = S1 + c

If InStr(Gl, c) > 0 Then

K = K + 1

If K > Len(Sh) Then K = 1

S1 = S1 + Mid(Sh, K, 1)

End If

Next i

For i = 1 To (Len(S1)) / 2

Call Swap(S1, i, Len(S1) - (i - 1))

Next i

S = S1

MsgBox (S)

End Sub

4

Sub ()

Dim S As String, Sh As String

Dim S1 As String, c As String

Dim Gl As String, K As Long

Dim i As Long

Sh = ""

S = InputBox(" ")

Gl = ""

For i = 1 To (Len(S1)) / 2

Call Swap(S1, i, Len(S1) - (i - 1))

Next i

For i = 1 To Len(S)

c = Mid(S, i, 1)

S1 = S1 + c

If InStr(Gl, c) > 0 Then

i = i + 1

End If

Next i

S = S1

MsgBox (S)

End Sub

5

Sub ()

Dim S As String, S1 As String

Dim n As Long, C As String

S = InputBox(" ")

n = 0

For i = 1 To Len(S)

C = Mid(S, i, 1)

If Mid(S, i, 1) = "#" Then

S1 = S1 + ""

i = i + 2

n = n + 1

ElseIf Mid(S, i, 3) = "" Then

S1 = S1 + "#"

i = i + 2

n = n + 1

Else

S1 = S1 + C

End If

Next i

MsgBox (S1)

MsgBox (n)

End Sub


5

1

DIM- .

Dim String as Type

String -

Type -

Byte

1

0-255

Integer

2

+ 32768

Long

4

+ 2 .

Double

4

.

+10+304

String

Len(String)

0-~64000

Boolean

2

True/False

1;0

Variant

16

.

2

Sub ( )

Dim S As String, Pr As String

Dim nPr As Integer, i As Long

S = InputBox(" ")

Pr = ",.?!:;"

nPr = 0

For i = 1 To Len(S)

If (InStr(Pr, Mid(S, i, 1))) > 0 Then

nPr = nPr + 1

End If

Next i

MsgBox ("- =" + Str(nPr))

End Sub

3

Sub Swap(S As String, i As Long, j As Long)

Dim c As String

c = Mid(S, i, 1)

Mid(S, i, 1) = Mid(S, j, 1)

Mid(S, j, 1) = c

End Sub

Sub ( )

Dim S As String, Sh As String

Dim S1 As String, c As String

Dim Gl As String, K As Long

Dim i As Long

Sh = ""

S = InputBox(" ")

Gl = ""

For i = 1 To Len(S)

c = Mid(S, i, 1)

S1 = S1 + c

If InStr(Gl, c) > 0 Then

K = K + 1

If K > Len(Sh) Then K = 1

S1 = S1 + Mid(Sh, K, 1)

End If

Next i

For i = 1 To Len(S1) - 1 Step 2

Call Swap(S1, i, i + 1)

Next i

For i = 1 To Len(S1) - 2 Step 3

Call Swap(S1, i, i + 2)

Next i

S = S1

MsgBox (S)

End Sub

4

Sub ( )

Dim S As String, i As Long

Dim S1 As String, c As String

Dim Gl As String, K As Long

S = InputBox(" ")

Gl = ""

For i = 1 To Len(S) - 2 Step 3

Call Swap(S, i, i + 2)

Next i

For i = 1 To Len(S) - 1 Step 2

Call Swap(S, i, i + 1)

Next i

For i = 1 To Len(S)

c = Mid(S, i, 1)

S1 = S1 + c

If InStr(Gl, c) > 0 Then i = i + 1

Next i

MsgBox (S1)

End Sub

5

Sub ()

Dim S As String, S1 As String

Dim n As Long, C As String

S = InputBox(" ")

n = 0

For i = 1 To Len(S)

C = Mid(S, i, 1)

If Mid(S, i, 1) = "&" Then

S1 = S1 + ""

n = n + 1

ElseIf Mid(S, i, 3) = "" Then

S1 = S1 + ""

i = i + 2

n = n + 1

Else

S1 = S1 + C

End If

Next i

MsgBox (S1)

MsgBox (n)

End Sub


6

1

Array()

Variant,

:

Dim m as Variant

m=Array(1,7,-1,2,3)

m(0)=1

m(1)=7

m(2)=-1

m(3)=2

m(4)=3

2

Sub ( )

Dim S As String, Pr As String

Dim nPr As Integer, i As Long

S = InputBox(" ")

Pr = ",.?!:;"

nPr = 0

For i = 1 To Len(S)

If (InStr(Pr, Mid(S, i, 1))) > 0 Then

nPr = nPr + 1

End If

Next i

MsgBox ("- =" + Str(nPr))

End Sub

3

Sub Swap(S As String, i As Long, j As Long)

Dim C As String

C = Mid(S, i, 1)

Mid(S, i, 1) = Mid(S, j, 1)

Mid(S, j, 1) = C

End Sub

Sub ()

Dim S As String, Sh As String

Dim S1 As String, c As String

Dim Gl As String, K As Long

Dim i As Long

Sh = ""

S = InputBox(" ")

Gl = ""

For i = 1 To Len(S)

c = Mid(S, i, 1)

S1 = S1 + c

If InStr(Gl, c) > 0 Then

K = K + 1

If K > Len(Sh) Then K = 1

S1 = S1 + Mid(Sh, K, 1)

End If

Next i

For i = 1 To Len(S1) - 3 Step 4

Call Swap(S1, i, i + 3)

Call Swap(S1, i + 1, i + 2)

Next i

S = S1

MsgBox (S)

End Sub

4

Sub ()

Dim S As String, i As Long

Dim S1 As String, c As String

Dim Gl As String, K As Long

S = InputBox(" ")

Gl = ""

For i = 1 To Len(S) - 3 Step 4

Call Swap(S, i, i + 3)

Call Swap(S, i + 1, i + 2)

Next i

For i = 1 To Len(S)

c = Mid(S, i, 1)

S1 = S1 + c

If InStr(Gl, c) > 0 Then i = i + 1

Next i

MsgBox (S1)

End Sub

1 1 Len (String)- String Left (String,Length)- Length String Right (String,Length)- Length String Mid (S

 

 

 

! , , , .
. , :