- , , .
.
.
.
, .
[Static| Public| Dim] _([ _ To] _) [ As _]
. (General) (Declarations) (Form, Module) . ReDim :
ReDim:
ReDim [Preserve] _() [ As _]
Dim ReDim . , Dim. Preserve (, ).
:
'(General) (Declarations)
Dim a() As Variant
Private Sub Command1_Click()
ReDim Preserve a(5,10)
.......
End Sub
(, ) :
Public ;
Dim - .
:
Lbound(, ) - .
Ubound(, ) - .
:
Dim ms() As String
Private Sub Command1_Click()
Cls
ReDim ms(0)
s = " "
Do Until s = ""
s = InputBox(" ")
ms(UBound(ms)) = s
ReDim Preserve ms(UBound(ms) + 1)
Loop
ReDim Preserve ms(UBound(ms) - 1)
For i = 0 To UBound(ms)
Print i; " "; ms(i)
Next i
End Sub
VISUAL BASIC .
:
Public Sub srt(b() As Integer)
Dim i As Integer, f As Integer, k As Integer
Do
f = 0
For i = LBound(b) To UBound(b) - 1
If b(i) > b(i + 1) Then
k = b(i): b(i) = b(i + 1): b(i + 1) = k: f = 1
End If
Next
Loop While f = 1
End Sub
Private Sub Command1_Click()
Dim a(1 To 5) As Integer
Dim i As Integer
For i = 1 To 5
a(i) = Val(InputBox(" "))
Next
Call srt(a)
Cls
For i = 1 To 5
Print a(i);
Next
End Sub
, :
Public Function VV(ByVal n As Byte) As Byte()
Dim x(1 To n) As Byte, i As Byte
For i = 1 To n
x(i) = Val(InputBox(" "))
|
|
Next
VV=x
End Function
Private Sub Commnd1_Click()
Dim b() As Byte, i As Byte
B()=VV(10)
For i = 1 To 10
Print b(i)
Next
End Sub
. :
;
;
;
.
/. . 1- 511. , . , , . , .
VISAUL BASIC FreeFile[()], , . ( ), . , :
- 0 ( ) - 1-255,
- 1 - 256 - 511.
VISAUL BASIC :
( );
( );
( ).
ASCII- . . .
( , ) :
Open For As
: ; , , , . ;
- , :
Input () - .
Output ()- , . .
Append () - , , .
- , . .
:
Close [ ]
- , . .
:
Print # , [ ]
Write # , [ ]
|
|
: - ( ).
. - , ( 13 10). .
Write Print .
Write
. , . String . .
, :
"", 1982
"", 1984
"", 1983
"", 1980
- .
. 7.16 Write.
. 7.16. 1. Write.
, . , :
(;) - , ;
(,) - 14- .
, :
Spc(n) - n ;
Tab(n) - n .
. 7.17 Print, .
. 7.17. 2. Print.
:
- Input #
- Line Input #
- Input ( , )
Input
- . .
Line Input
- String Variant. - .
Input
- , . . .
. 7.18 1.txt, .
Input:
Private Sub Command3_Click()
Dim ks As Integer
Open "c:\1.txt" For Input As #1
ks = LOF(1)
Print Input(ks, #1)
Close #1
End Sub
, Line Input:
Line Input:
Private Sub Command3_Click()
Dim ts As String
Open "c:\1.txt" For Input As #1
Do Until EOF(1)
Line Input #1, ts
Print ts
Loop
Close #1
End Sub
: EOF () - True, False - .
LOF () - .