alex101fishing
Member
- Joined
- Dec 30, 2011
- Messages
- 18
- Programming Experience
- 3-5
Hey all,
Having a bit of the problem with the code shown below, i keep getting a conversion error from "string to integer is not valid" but I can't quite figure out why
Basically there is an " " seperated input string that holds a series of numbers, i want to split this up, populate an array with them, and then re-order them into numerical order 0 - 100 say.
As far as i can tell this should work, would very much appreciate a helping hand, thanks in advance!
Having a bit of the problem with the code shown below, i keep getting a conversion error from "string to integer is not valid" but I can't quite figure out why
Basically there is an " " seperated input string that holds a series of numbers, i want to split this up, populate an array with them, and then re-order them into numerical order 0 - 100 say.
As far as i can tell this should work, would very much appreciate a helping hand, thanks in advance!
VB.NET:
frmCustomReports.textbox1.Text = Row_Ignorer_List 'prints the original space seperated string in the original order
Dim Arr() As String 'Declare an array which will hold all of the numbers
Arr = Row_Ignorer_List.Split(" ") 'splits up the string
Dim Row_Ignorer_list_2 As String = " "
Dim i, j As Integer
For i = 0 To Arr.Count - 2 'if there are for example 10 items then arr(9) is the upperbound
For j = i + 1 To Arr.Count - 1 'as start is from 0, we have to - 1 to give a true count.
Dim Pos1 As Integer = Arr(i) 'creates a variable to hold array object i
Dim pos2 As Integer = Arr(j) 'creates a variable to hold array object j
If Arr(i) > Arr(j) Then 'if I is greater than J it swaps them over
Arr(i) = pos2
Arr(j) = Pos1
End If
Next j
Row_Ignorer_list_2 = Row_Ignorer_list_2 & Arr(i) & " " 'Creates a new space seperated string with the numbers in the new order
Next i
frmCustomReports.TextBox2.Text = Row_Ignorer_list_2 'displays them into a text box