Question Array not displaying correctly

otester

New member
Joined
Nov 22, 2010
Messages
4
Programming Experience
1-3
VB.NET:
Public Function list_process(ByRef item_location As Integer, ByRef add_single As Boolean, ByRef selected_list As String)
        Dim list_counter As Integer = 0
        Dim item_address As Integer = 0
        Dim list_size = CInt(Int(6 * Rnd()))
        Dim ran_generator As Integer = 0

        Init_Arrays()

        ran_generator = CInt(Int((selected_list.Length - 1) * Rnd()))

        If (add_single = False) Then
            Form1.ListView1.Items.Clear()
            For list_counter = 0 To list_size Step 1
                Form1.ListView1.Items.Insert(item_address, selected_list(ran_generator))
                ran_generator = CInt(Int((selected_list.Length - 1) * Rnd()))
                item_address = item_address + 1
            Next list_counter
        ElseIf (add_single = True) And Not (Form1.ListView1.Items.Count = 6) Then
            'Form1.ListView1.Items.Add(selected_list(ran_generator))
            Form1.ListView1.Items.Add(Attributes_List(ran_generator))
            chk_add_btns()
        End If
    End Function


I have an array in a Module file, the program will need to be expandable list-wise so I decided to make a function that could manage it.

selected_list.Length

returns the correct value (size of an array), however..

Form1.ListView1.Items.Add(selected_list(ran_generator))

does not (meant to add items from the array - currently seems to add random letters/special characters). I have confirmed this by using MsgBox's to confirm the values of selected list and ran_generator, and replacing selected list with the actual array name (which works), seems that

Form1.ListView1.Items.Add

can't handle it, is there any way to get this work?


Any help would be greatly appreciated,

Thanks,

otester
 
Back
Top