|
-
Jul 2nd, 2003, 04:48 PM
#1
Thread Starter
Lively Member
Using Arrays....
Alrighty...
I want to say:
Code:
If <Variable> = Array1(<any item in the array>) then
do something
end if
But i cant just use Array() or array
Second,
Can you alphabitize objects in an array?
-
Jul 2nd, 2003, 05:06 PM
#2
Sleep mode
VB Code:
Dim ary() As String = {"one", "two", "three"}
If ary(1) = "two" Then
MessageBox.Show("second element is : Two")
End If
-
Jul 2nd, 2003, 05:08 PM
#3
Sleep mode
Maybe you mean this one .
VB Code:
Dim ary() As String = {"one", "two", "three"}
Dim str As String = "two"
If str = ary(1) Then
MessageBox.Show("second element is : Two")
End If
-
Jul 2nd, 2003, 05:17 PM
#4
Depending on what is contained in the array you can probably use:
VB Code:
Dim ary() As String = {"one", "two", "three"}
Dim idx As Integer=ary.IndexOf("one")
If idx > -1 Then
MessageBox.Show(String.Format("Found in element: {0}",idx))
End If
-
Jul 2nd, 2003, 05:20 PM
#5
Thread Starter
Lively Member
I think E is more twards what i want, but havent tested it, will that check the whole array for what im looking for?
-
Jul 2nd, 2003, 05:32 PM
#6
Thread Starter
Lively Member
Dim idx As Integer=ary.IndexOf("one")
that isnt working for me
-
Jul 2nd, 2003, 05:32 PM
#7
Yes and return the index of the first found match. Although if the array contains objects then it may try to match an instance which can be tricky. Although I'm not sure of this, I haven't actually tested it yet.
-
Jul 2nd, 2003, 07:31 PM
#8
Thread Starter
Lively Member
Well, i want it to do something if there is NO match
-
Jul 2nd, 2003, 09:01 PM
#9
It returns -1 if there is no match found.
-
Jul 2nd, 2003, 11:10 PM
#10
Thread Starter
Lively Member
Ah cool, but...
users.LastIndexOf(uid)
Overload resolution failed because no accessible 'LastIndexOf' accepts this number of arguments.
-
Jul 3rd, 2003, 12:22 AM
#11
You are using the wrong method its not LASTIndexOf its just IndexOf.
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
|