Answered by:
VB Is telling me that i can't sort my array... and i have no clue why

Question
-
Here is my code: i have NO idea what is wrong. It is telling me that .sort and .reverse are NOT valid statements. uhm... why?
Public Class array
Private strThings(5) As String
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Add.Click
clearlist()
strThings(0) = "Hello, and welcome"
strThings(1) = "What are you doing?"
strThings(2) = "Why are you doing that?"
strThings(3) = "Why dont you do this?"
strThings(4) = "What is your name?"
strThings(5) = "What is his name?"
For num As Integer = 0 To (strThings.Length - 1)
listArrays.Items.Add(strThings(num))
Next
End Sub
Private Sub clearlist()
listArrays.Items.Clear()
End Sub
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Clear.Click
clearlist()
End Sub
Private Sub btnSort_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Sort.Click
clearlist()
strThings(0) = "Hello, and welcome"
strThings(1) = "What are you doing?"
strThings(2) = "Why are you doing that?"
strThings(3) = "Why dont you do this?"
strThings(4) = "What is your name?"
strThings(5) = "What is his name?"
array.Sort(strThings)
For num As Integer = 0 To strThings.Length - 1
listArrays.Items.Add(strThings(num))
Next
End Sub
Private Sub reverse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles reverse.Click
clearlist()
strThings(0) = "Hello, and welcome"
strThings(1) = "What are you doing?"
strThings(2) = "Why are you doing that?"
strThings(3) = "Why dont you do this?"
strThings(4) = "What is your name?"
strThings(5) = "What is his name?"
array.reverse(strThings)
For num As Integer = 0 To strThings.Length - 1
listArrays.Items.Add(strThings(num))
Next
End SubEnd Class
Tuesday, November 27, 2012 7:51 PM
Answers
-
Change the name of your class
You have named your class "Array" so the compiler gets mixed up,
when you typed "Array.Sort"
it thinks that you are referring to your class, not to the System.Array class
- Edited by Crazypennie Tuesday, November 27, 2012 8:43 PM
- Marked as answer by Mark Liu-lxfModerator Wednesday, December 5, 2012 7:06 AM
Tuesday, November 27, 2012 8:40 PM
All replies
-
Change the name of your class
You have named your class "Array" so the compiler gets mixed up,
when you typed "Array.Sort"
it thinks that you are referring to your class, not to the System.Array class
- Edited by Crazypennie Tuesday, November 27, 2012 8:43 PM
- Marked as answer by Mark Liu-lxfModerator Wednesday, December 5, 2012 7:06 AM
Tuesday, November 27, 2012 8:40 PM -
i feel like that is a really stupid mistake...
thank you though!
Wednesday, December 5, 2012 4:02 AM