|
-
Feb 26th, 2009, 05:16 AM
#1
Thread Starter
Member
[RESOLVED] Copying array contents to listboxes
I am having a hell of a time figuring out where I am going wrong in copying the contents of arrays to listboxes. I am sure it is quite simple but I just cannot figure out where the code is going wrong.
I am using textboxes to input team numbers and team names.
The code for that is as follows (used in a button after the data has been entered in the text boxes:
Teamname, Teamnumber and numteams have been previously declared as public variables (string,integer and integer) in a module as they are used throughout the project.
Numteams has had a value ascribed to it in a previous form
ReDim Teamname(Numteams)
ReDim Teamnumber(Numteams)
Dim thisteam As Integer
thisteam = (Val(TxtNumber.Text) - 1)
Teamname(thisteam) = TxtNames.Text
Teamnumber(thisteam) = Val(TxtNumber.Text)
TxtNumber.Text = ""
TxtNames.Text = ""
TxtNumber.Focus()
Once all of the data has been entered, I am trying to transfer the data to listboxes on another form as follows:
For i = 0 To (Numteams - 1)
Results.Tmname.Items.Add("" &Teamname(i))
Results.TmNumber.Items.Add(Teamnumber(i))
Next
I have had to put in the "" for the Teamname variable as otherwise I was getting an error saying "Value cannot be null". I am also not sure what is causing that.
When I do that, I get 0 in the listboxes for all the teamnumbers except the last one which is right and blank strings for the team names except for the last one which is also right.
Can somone point me in the right direction please?
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
|