|
-
Sep 14th, 2009, 01:02 PM
#1
Re: looking in a array and loop it
 Originally Posted by Warbringer
I know the values already yeah, and they need to be hardcoded (values never change).
In that case, one way I can think of is
Code:
'Declared Array
Dim x(5) As String
Dim iCounter As Integer
Private Sub Command1_Click()
'Assigned Values
x(0) = "India": x(1) = "China": x(2) = "Brazil": x(3) = "Russia": x(4) = "Yemen"
'Looped Through Array
For iCounter = 0 To UBound(x) - 1
If x(iCounter) = "China" Then
Debug.Print "Hello China"
End If
Next
End Sub
Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
save a blobFileStreamDataTable To Text Filemy blog
-
Sep 14th, 2009, 01:48 PM
#2
Thread Starter
New Member
Re: looking in a array and loop it
Okey, my code so far:
Code:
'Declared Array
Dim x(6) As String
Dim y(6) As String
Dim iCounter As Integer
Private Sub Command1_Click()
'Assigned Values
x(0) = "414,622": x(1) = "431,82": x(2) = "413,685": x(3) = "421,604": x(4) = "429,794": x(5) = "413,557"
y(0) = "-400,55": y(1) = "-392,107": y(2) = "-380,754": y(3) = "-377,159": y(4) = "-363,381": y(5) = "-360,796"
'Looped Through Array
For iCounter = 0 To UBound(x) - 1
'check if something equials the x array
If x(iCounter) = "China" Then
Debug.Print "x found"
End If
'check if something equials the y array
If x(iCounter) = "China" Then
Debug.Print "y found"
End If
Next
End Sub
Is there something like 'BETWEEN' ? i.e.
'check if something equials the x array
If x(iCounter) BETWEEN x(iCounter) -5 And x(iCounter) +5 Then
so i have a marge of 10 ?
-
Sep 14th, 2009, 02:18 PM
#3
Re: looking in a array and loop it
 Originally Posted by Warbringer
Okey, my code so far:
Code:
'Declared Array
Dim x(6) As String
Dim y(6) As String
Dim iCounter As Integer
Private Sub Command1_Click()
'Assigned Values
x(0) = "414,622": x(1) = "431,82": x(2) = "413,685": x(3) = "421,604": x(4) = "429,794": x(5) = "413,557"
y(0) = "-400,55": y(1) = "-392,107": y(2) = "-380,754": y(3) = "-377,159": y(4) = "-363,381": y(5) = "-360,796"
'Looped Through Array
For iCounter = 0 To UBound(x) - 1
'check if something equials the x array
If x(iCounter) = "China" Then
Debug.Print "x found"
End If
'check if something equials the y array
If x(iCounter) = "China" Then
Debug.Print "y found"
End If
Next
End Sub
Is there something like 'BETWEEN' ? i.e.
'check if something equials the x array
If x(iCounter) BETWEEN x(iCounter) -5 And x(iCounter) +5 Then
so i have a marge of 10 ?
For numeric variables, you could always do a comparison using the standard comparison operators.
Code:
If x(iCounter) < 10 AND x(iCounter) > 5 Then
Debug.print "Number between 10 and 5"
End If
Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
save a blobFileStreamDataTable To Text Filemy blog
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|