You are on page 1of 35

Under Tiker

www.arabmoheet.net

PDF created with pdfFactory Pro trial version www.pdffactory.com

: ) (
) (

2006/03/01



) (
) (

-2-

PDF created with pdfFactory Pro trial version www.pdffactory.com

: ) (
) (

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-

PDF created with pdfFactory Pro trial version www.pdffactory.com

: ) (
) (

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-

PDF created with pdfFactory Pro trial version www.pdffactory.com

: ) (
) (

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

Dim ArrName(Len) As DataType

Len

Option Base :
Option Base 1
)(
.

-5-

PDF created with pdfFactory Pro trial version www.pdffactory.com

: ) (
) (

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-

PDF created with pdfFactory Pro trial version www.pdffactory.com

: ) (
) (

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-

PDF created with pdfFactory Pro trial version www.pdffactory.com

: ) (
) (

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-

PDF created with pdfFactory Pro trial version www.pdffactory.com

: ) (
) (

2006/03/01

..

.

) (
.

: ReDim
ReDim [Preserve] ArrayName(Length) As DataType

ReDim
.
) ( Preserve .
ReDim
Preserve
Preserve

)
(
) ( ArrayName .
) ( Length .
) ( DataType , .

:

Dim ArrName() As Double

) ( :

ReDim ArrName (49) As Double


ArrName (0) =25.50
ArrName (1) =12.75
.
.
.
ArrName (49) =40.30

-9-

PDF created with pdfFactory Pro trial version www.pdffactory.com

: ) (
) (

2006/03/01

) ( :

Preserve:
ReDim Preserve ArrName(50) As Double

)ArrName(50
:
ArrName(50)=32.10
: Redim
) ( Dim

- 10 -

PDF created with pdfFactory Pro trial version www.pdffactory.com

: ) (
) (

2006/03/01

:
MultiDimensional Arrays

:



.

) - (


.

.
..
.
.
.

:

.
) ( 2 Index

.

- 11 -

PDF created with pdfFactory Pro trial version www.pdffactory.com

: ) (
) (

2006/03/01

:
,
.
...

Visual Basic 60 !!
.
) (
.
.

-1 :
Dim ArrayName(MaxCols,MaxRows) As DataType


Dim Public Private
ArrayName

MaxCols MaxRows

: MaxCols )(
:MaxRows )(

DataType

- 12 -

PDF created with pdfFactory Pro trial version www.pdffactory.com

: ) (
) (

2006/03/01

) ( :

Dim XArray(3, 5) As STRING

:
:XArray
3

: ) 4(

: ) 6(

:STRING .

)( 24
) 4(
) 6(
24 = 6 * 4 ) (

- 13 -

PDF created with pdfFactory Pro trial version www.pdffactory.com

: ) (
) (

2006/03/01

) ( :

Dim XArray (8, 10, 12) as Double

:
:XArray
8

: ) 9(

10

: ) 11(

12

: ) 13(

:Double .
)(
1287
) 9(
) 11(
) 13(

1287 = 13 * 11 * 9 ) (

- 14 -

PDF created with pdfFactory Pro trial version www.pdffactory.com

: ) (
) (

2006/03/01

-2 :

Dim ArrayName(MinCols to MaxCols, MinRows to MaxRows) As DataType

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 -

PDF created with pdfFactory Pro trial version www.pdffactory.com

: ) (
) (

2006/03/01

-3 ) (.
:

Dim ArrName() As DataType


ReDim .

,
.
:

Dim ArrName() As String


)ReDim ArrName(2,2

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 -

PDF created with pdfFactory Pro trial version www.pdffactory.com

: ) (
) (

2006/03/01

:

Option Base
, ReDim
.
Preserve
.

Dim XArray() as Integer


)ReDim XArray(2,3

)ReDim Preserve XArray(2,8


)ReDim Preserve XArray(3,3
.

- 17 -

PDF created with pdfFactory Pro trial version www.pdffactory.com

: ) (
) (

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 -

PDF created with pdfFactory Pro trial version www.pdffactory.com

: ) (
) (

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 -

PDF created with pdfFactory Pro trial version www.pdffactory.com

: ) (
) (

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 -

PDF created with pdfFactory Pro trial version www.pdffactory.com

: ) (
) (

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 -

PDF created with pdfFactory Pro trial version www.pdffactory.com

: ) (
) (

2006/03/01

:
Dim Xarr(2) As String
"Xarr(1) = "01/01/2005
'
If CDate(Xarr(1)) < Date Then
" " MsgBox
End If

- 22 -

PDF created with pdfFactory Pro trial version www.pdffactory.com

: ) (
) (

2006/03/01

Dim Arr(5) As Integer

Arr(0) = 8011
Arr(1) = 2055
Arr(2) = 4066
Arr(3) = 3044
Arr(4) = 6088
Arr(5) = 1000






..

- 23 -

PDF created with pdfFactory Pro trial version www.pdffactory.com

: ) (
) (

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 -

PDF created with pdfFactory Pro trial version www.pdffactory.com

: ) (
) (

2006/03/01

:

) (

:


) 10 (
) 30 (
) 60 (

) + + (

-1 : 90
-2 : 80
-3 : 70
-4 :

:
Dim X_Arr() As String

- 25 -

PDF created with pdfFactory Pro trial version www.pdffactory.com

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 -

PDF created with pdfFactory Pro trial version www.pdffactory.com

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 -

PDF created with pdfFactory Pro trial version www.pdffactory.com

: ) (
) (

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 -

PDF created with pdfFactory Pro trial version www.pdffactory.com

2006/03/01

( ) :
()

Private Sub DatGrid()


'
MSFlexGrid1.Clear
'
MSFlexGrid1.Cols = 7
'
MSFlexGrid1.Rows = 2
'
MSFlexGrid1.FixedRows = 1
'
MSFlexGrid1.FixedCols = 0

'
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 -

PDF created with pdfFactory Pro trial version www.pdffactory.com

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 -

PDF created with pdfFactory Pro trial version www.pdffactory.com

: ) (
) (

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 -

PDF created with pdfFactory Pro trial version www.pdffactory.com

: ) (
) (

2006/03/01

Dim XArray(4, 3) As STRING -22


12.
-23
ReDim Preserve

Dim XArray (2,8) As String


Dim XArr2 () As String
XArray (3,1) = Ahmad
XArray (4,2) = Ali
XArr2 (2) = 120
Text1 = XArray

- 32 -

PDF created with pdfFactory Pro trial version www.pdffactory.com

: ) (
) (

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 -

PDF created with pdfFactory Pro trial version www.pdffactory.com

: ) (
) (

2006/03/01

Dim XArray(3 to 5) As STRING -21


... .
Dim XArray(4, 3) As STRING -22
... 20.
-24 ...
.ReDim Preserve

Dim XArray (2,8) As String

Dim XArr2 () As String


-1 " "
-2 ..
.. 2 3

-1 " "
-2 ..
.. 2 4


XArr2 .

XArray (3,1) = Ahmad

XArray (4,2) = Ali

XArr2 (2) = 120

Text1 = XArray
.Text1

- 34 -

PDF created with pdfFactory Pro trial version www.pdffactory.com

: ) (
) (

2006/03/01

:
:

- 35 -

PDF created with pdfFactory Pro trial version www.pdffactory.com

You might also like