Under Tiker: PDF Created With Pdffactory Pro Trial Version
Under Tiker: PDF Created With Pdffactory Pro Trial Version
Under Tiker: PDF Created With Pdffactory Pro Trial Version
www.arabmoheet.net
: ) (
) (
2006/03/01
) (
) (
-2-
: ) (
) (
2006/03/01
) (Array )(
)( Index
.
).(Index
) (Index
.
:
..
) (
) (
1 2 ... 3
.
.Index
:
) (Index .
,
100
200
)( .
:
-1
-2 .
-3 .
-4
Visual Basic
.
:
-1 Single Dimensional Array
-2 Multi Dimensional Arrays
.
-3-
: ) (
) (
2006/03/01
:
:
.
:
.
:
Dim ArrName(Len) AS DataType
) ( SCOPE:
Dim Public Private
:
: Private -1
.
: Public -2
) (
: Dim -3 Private
Public
.
ArrName
Len
Len=4 5
. .
DataType .
-4-
: ) (
) (
2006/03/01
:
50
50 .. :
Dim Stud(49) As String
-
Stud
50 , .
String
:
:
"Stud(0) ="Ali Ahmad
"Stud(1) ="Majed Nabil
"Stud(2) ="Saleh Khaled
"Stud(49) ="UnderTaker
.
.
:
) " "( Double Quotation
:
)Text1.Text=Stud(20
)Text2.Text=Stud(1
)Text3.Text=Stud(40
.
.
.
-1 ) (.
:
Len
Len
Option Base :
Option Base 1
)(
.
-5-
: ) (
) (
2006/03/01
:
Option Base
Option Base 0
Option Base 1
:
Dim Arr(2) As String
- 1 Option Base Arr:
"Arr(0) ="AAA
"Arr(1) ="DDD
"Arr(2) ="VVV
- 2 Option Base Arr:
"Arr(1) ="DDD
"Arr(2) ="VVV
..
.
) ( Option Base
. Error
:
-2
) (.
Option Base 1
.Option Base
) (
Error.
: 1
Dim ArrName(Str_Len TO End_Len) As DataType
Str_Len .
End_Len .
-6-
: ) (
) (
2006/03/01
:2
Dim XArray(2 To 4) As String
2 .
4 .
XArray
String
, 3
"XArray(2) ="AAA
"XArray(3) ="BBB
"XArray(4) ="SSS
-3 ) (.
:
Dim ArrName() As DataType
ReDim
:
Dim ArrName() As String
)ReDim ArrName(2
"ArrName(0) = "AAA
"ArrName(1) = "BBB
"ArrName(2) = "CCC
-7-
: ) (
) (
2006/03/01
-4 Variant )(Array
.
:
Dim ArrName as Variant
)"ArrName = Array("Ali","UnderTiker","Mazen","Yaser
ArrName
:
0
3
Option Base
1
4
:
-1 : ) (Fixed Size
.
-2 : Dynamic
.ReDim
:
-1 Visual Basic
.
-2 .
.
:
-1 .
-2 .
-8-
: ) (
) (
2006/03/01
..
.
) (
.
: ReDim
ReDim [Preserve] ArrayName(Length) As DataType
ReDim
.
) ( Preserve .
ReDim
Preserve
Preserve
)
(
) ( ArrayName .
) ( Length .
) ( DataType , .
:
Dim ArrName() As Double
) ( :
-9-
: ) (
) (
2006/03/01
) ( :
Preserve:
ReDim Preserve ArrName(50) As Double
)ArrName(50
:
ArrName(50)=32.10
: Redim
) ( Dim
- 10 -
: ) (
) (
2006/03/01
:
MultiDimensional Arrays
:
.
) - (
.
.
..
.
.
.
:
.
) ( 2 Index
.
- 11 -
: ) (
) (
2006/03/01
:
,
.
...
Visual Basic 60 !!
.
) (
.
.
-1 :
Dim ArrayName(MaxCols,MaxRows) As DataType
Dim Public Private
ArrayName
MaxCols MaxRows
: MaxCols )(
:MaxRows )(
DataType
- 12 -
: ) (
) (
2006/03/01
) ( :
:
:XArray
3
: ) 4(
: ) 6(
:STRING .
)( 24
) 4(
) 6(
24 = 6 * 4 ) (
- 13 -
: ) (
) (
2006/03/01
) ( :
:
:XArray
8
: ) 9(
10
: ) 11(
12
: ) 13(
:Double .
)(
1287
) 9(
) 11(
) 13(
1287 = 13 * 11 * 9 ) (
- 14 -
: ) (
) (
2006/03/01
-2 :
DIM
ArrayName
MinCols
MaxCols
MinRows
MaxRows
DataType
) ( :
Dim XArray(2 TO 4, 4 TO 8) As STRING
:
2 4 3.
:
4 8 5.
)( 25
) 3(
) 5(
25 = 5 * 3 ) (
- 15 -
: ) (
) (
2006/03/01
-3 ) (.
:
ReDim .
,
.
:
ArrName
3 3
:
:
50
50 50 ..
:
Dim Stud(1,49) As String
-
Stud
100 , 2 50
100 = 50 * 2 )(
String
:
:
"Stud(0,0) ="Ahmad
Stud(1,0) =88
"Stud(0,1) ="Ali
Stud(1,1) =79
" Stud(0,2) ="Majed
Stud(1,2) =100
.
.
)Text1.Text= Stud(0,0
)Text2.Text= Stud(1,0
)Text3.Text= Stud(0,1
.
.
.
- 16 -
: ) (
) (
2006/03/01
:
Option Base
, ReDim
.
Preserve
.
)ReDim Preserve XArray(3,3
.
- 17 -
: ) (
) (
2006/03/01
For
For
,
: FOR
FOR I = Xstart TO Xend
NEXT I
FOR
: Xstart
Xend
: NEXT I
:
FOR NEXT
Xstart
Xend ) ( I ) ( I
Xend .
:
.
- 18 -
: ) (
) (
2006/03/01
:
6
TO
FOR I = 1
IF I = 4 THEN
EXIT FOR
END IF
NEXT I
:
4 2 3 .
STEP
:
10
10 STEP 2
TO
FOR I = 0
MsgBox I
NEXT I
0 , 2 , 4 , 6 , 8 , 10
2
:
0 STEP -2
TO
FOR I = 10
MsgBox I
NEXT I
10 , 8 , 6 , 4 , 2 , 0
- 19 -
: ) (
) (
2006/03/01
INDEX
.
:
1 100
Dim Xarr(1 To 100) As Integer
For I = 1 To 100
Xarr(I) = I
Next I
Ubound
)Ubound ( NAME ARRAY
NAME ARRAY
:
Dim Xarr(1 To 100) As Integer
)MsgBox UBound(Xarr
100
- 20 -
: ) (
) (
2006/03/01
:
String Variant
:
Integer CInt
Boolean CBool
Byte CByte
Currency CCur
Data CDate
Double CDbl
Single CSng
String CStr
Variant CVar
:
Dim a As String
Dim b As String
a = 10
b = 20
MsgBox a + b
)MsgBox CInt(a) + CInt(b
1020
30
- 21 -
: ) (
) (
2006/03/01
:
Dim Xarr(2) As String
"Xarr(1) = "01/01/2005
'
If CDate(Xarr(1)) < Date Then
" " MsgBox
End If
- 22 -
: ) (
) (
2006/03/01
Arr(0) = 8011
Arr(1) = 2055
Arr(2) = 4066
Arr(3) = 3044
Arr(4) = 6088
Arr(5) = 1000
..
- 23 -
: ) (
) (
2006/03/01
'
Dim X_Var As Integer
'
'
For I = 0 To 5
'
For z = 0 To 5
'
If Arr(I) < Arr(z) Then
'
(X_Var = Arr(I
(Arr(I) = Arr(z
Arr(z) = X_Var
End If
Next z
Next I
ListBox:
For I = 0 To 5
(List2.List(I) = Arr(I
Next I
UnderTiker_Arr1.rar
- 24 -
: ) (
) (
2006/03/01
:
) (
:
) 10 (
) 30 (
) 60 (
) + + (
-1 : 90
-2 : 80
-3 : 70
-4 :
:
Dim X_Arr() As String
- 25 -
2006/03/01
( ) :
()
7
( - - - - - - )
RecordCount
Dim X_Count As Integer
X_Count = RecSet.RecordCount
ReDim X_Arr(1 To 7, 1 To X_Count) As String
: :
For i = 1 To X_Count
If RecSet.EOF Then Exit For
X_Arr(1, i) = RecSet.Fields.Item("No_Stud").Value
X_Arr(2, i) = RecSet.Fields.Item("Name").Value
X_Arr(3, i) = RecSet.Fields.Item("Mark_Month").Value
X_Arr(4, i) = RecSet.Fields.Item("Mark_Half").Value
X_Arr(5, i) = RecSet.Fields.Item("Mark_Final").Value
RecSet.MoveNext
Next i
- 26 -
2006/03/01
( ) :
()
( - ) :
:
'
Dim X_Result As Double
For i = 1 To X_Count
'
X_Result = 0
X_Result = CDbl(X_Arr(3, i)) + CDbl(X_Arr(4, i)) + CDbl(X_Arr(5, i((
X_Arr(6, i) = X_Result
'
Select Case X_Result
Case Is >= 90
X_Arr(7, i)=""
Case Is >= 80
X_Arr(7, i)=""
Case Is >= 70
X_Arr(7, i)=""
Case Else
X_Arr(7, i)=""
End Select
Next i
- 27 -
: ) (
) (
2006/03/01
MSFlexGrid1
'
For i = 1 To X_Count
'
MSFlexGrid1.Row = MSFlexGrid1.Rows - 1
'
For z = 0 To 6
'
MSFlexGrid1.Col = z
'
(MSFlexGrid1.Text = X_Arr(z + 1, i
Next z
'
MSFlexGrid1.Rows = MSFlexGrid1.Rows + 1
Next i
- 28 -
2006/03/01
( ) :
()
'
MSFlexGrid1.Row = 0
MSFlexGrid1.Col = 0
MSFlexGrid1.Text" = "
MSFlexGrid1.Col = 1
MSFlexGrid1.Text"= "
MSFlexGrid1.Col = 2
MSFlexGrid1.Text"= "
MSFlexGrid1.Col = 3
MSFlexGrid1.Text"= "
MSFlexGrid1.Col = 4
MSFlexGrid1.Text"= "
MSFlexGrid1.Col = 5
MSFlexGrid1.Text"= "
MSFlexGrid1.Col = 6
MSFlexGrid1.Text"= "
- 29 -
2006/03/01
( ) :
()
'
MSFlexGrid1.ColWidth(0) = 1000
MSFlexGrid1.ColWidth(1) = 2000
MSFlexGrid1.ColWidth(2) = 1000
MSFlexGrid1.ColWidth(3) = 1000
MSFlexGrid1.ColWidth(4) = 1000
MSFlexGrid1.ColWidth(5) = 1000
MSFlexGrid1.ColWidth(6) = 1000
'
For i = 0 To 6
MSFlexGrid1.ColAlignment(i) = 3
MSFlexGrid1.FixedAlignment(i) = 3
Next i
End Sub
UnderTiker_Arr2.rar
- 30 -
: ) (
) (
2006/03/01
:
-1 Index
-2 .
-3 Index.
-4
.
-5 .
-6 .
-7 Public .
Dim Arr(100) As String -8
100 . String
-9 Option Base .
-10 Option
Base .
-11 Option Base
Dim Arr(3 TO 4) As Intger -12
Intger
-13 .
-14 Array .
-15
Array
-16 Preserve
.
-17
ReDim
-18 .
-19 .
-20 60 .
Dim XArray(3 to 5) As STRING -21
- 31 -
: ) (
) (
2006/03/01
- 32 -
: ) (
) (
2006/03/01
-1 ... .
-2 ... .
-3 ... Index.
-4 ...
.
-5 ... .
-6 ... ) ( SCOPE.
-7 ... Public
.
Dim Arr(100) As String -8
... 101 , String
.Option Base 1
-9 ... Option Base ,
Option Base .
-10 ...
Option Base .
-11 ...
.Option Base
Dim Arr(3 TO 4) As Intger -12
... Intger
-13 ... ,.
ReDim
-14 ... Array Variant.
-15 ...
.ReDim
-16 ... Preserve
.
-17 ...
.ReDim
-18 ... .
-19 ... .
-20 ... 60 .
- 33 -
: ) (
) (
2006/03/01
-1 " "
-2 ..
.. 2 3
-1 " "
-2 ..
.. 2 4
XArr2 .
Text1 = XArray
.Text1
- 34 -
: ) (
) (
2006/03/01
:
:
- 35 -