Yes, this is for school. No, it is not a graded assignment. This is part of the lab for end of the week, and I am not understanding how to accomplish this.
Here are the tasks:
· Create two arrays, ask the user to populate them and display both arrays
· Swap the contents of the arrays using loops and then display the content.
What is the best method to have the end user populate an array? I am doing this as a windows form. Have multiple text boxes that they have to fill out? Set the elements of the array to the text box values? And how to swap the contents at run time is something I am not sure of. Isn't there a Array Swap function or something?
Thanks
Here is what I have so far:
Note: the bottom section was a test..and it isn't working as expected.
Here are the tasks:
· Create two arrays, ask the user to populate them and display both arrays
· Swap the contents of the arrays using loops and then display the content.
What is the best method to have the end user populate an array? I am doing this as a windows form. Have multiple text boxes that they have to fill out? Set the elements of the array to the text box values? And how to swap the contents at run time is something I am not sure of. Isn't there a Array Swap function or something?
Thanks
Here is what I have so far:
Note: the bottom section was a test..and it isn't working as expected.
VB.NET:
Public Class Form1
Dim numberarray(3) As Integer
Dim numberarray2(3) As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
numberarray(0) = txtOneOne.Text
numberarray(1) = txtOneTwo.Text
numberarray(2) = txtOneThree.Text
numberarray(3) = txtOneFour.Text
numberarray2(0) = txtTwoOne.Text
numberarray2(1) = txtTwoTwo.Text
numberarray2(2) = txtTwoThree.Text
numberarray2(3) = txtTwoFour.Text
For i As Integer = 0 To numberarray.Count - 1
MsgBox(numberarray(i).ToString)
Next
Dim tmp As String
tmp = numberarray(0)
numberarray(0) = numberarray(1)
numberarray(1) = tmp
tmp = Nothing
MsgBox("After:")
For i As Integer = 0 To numberarray.Count - 1
MsgBox(numberarray(i).ToString)
Next
End Sub
End Class