Basically, the user will enter a name and a number. they enter the array sizes(i)
After the user enters 7 names and numbers they have the opportunity to see the array.
I have added a button that will produce the Maximum number in the array. I have set the first array element the maximum.
Heres all my code:
Public Class frmCreateArray
Dim Names(7) As String
Dim Sizes(7) As String
Dim NamesCount As Integer
Dim SizeCount As Integer
Dim Index1 As Integer
Dim Index2 As Integer
Dim TempNamez As String
Dim TempIndex2 As String
Dim TempSizez As String
Dim Max As Integer
Dim MaxIndex As Integer
Private Sub lblCounter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblCounter.Click
End Sub
Private Sub cmdEnterThisName_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdEnterThisName.Click
NamesCount = NamesCount + 1 'increments the index
Names(NamesCount) = txtNamesGoHere.Text 'inputs each name
SizeCount = SizeCount + 1
Sizes(SizeCount) = txtSizesGohere.Text
lblCounter.Text = Str(NamesCount) + " Names enterred"
txtNamesGoHere.Clear()
txtNamesGoHere.Focus()
txtSizesGohere.Clear()
End Sub
Private Sub frmCreateArray_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
NamesCount = 0 ' initialises the index to 0
SizeCount = 0
End Sub
Private Sub cmdShowListArray_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdShowListArray.Click
lstListNames.Items.Clear()
lstListSizes.Items.Clear()
For Me.NamesCount = 1 To 7 ' starts loop counting thru the names
lstListNames.Items.Add(Names(NamesCount)) 'adds each name to list
Next
For Me.SizeCount = 1 To 7
lstListSizes.Items.Add(Sizes(SizeCount))
Next
End Sub
Private Sub Swap_Btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SwapBtn.Click
Index1 = Index1Txt.Text
Index2 = Index2Txt.Text
TempNamez = Names(Index1)
Names(Index1) = Names(Index2)
Names(Index2) = TempNamez
TempSizez = Sizes(Index2)
Sizes(Index1) = Sizes(Index2)
Sizes(Index2) = TempSizez
lstListNames.Items.Clear()
lstListSizes.Items.Clear()
For Me.NamesCount = 1 To 7 ' starts loop counting thru the names
lstListNames.Items.Add(Names(NamesCount)) 'adds each name to list
Next
For Me.SizeCount = 1 To 7
lstListSizes.Items.Add(Sizes(SizeCount))
Next
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
End Sub
End Class
Here's what it looks like:
http://puu.sh/1iQoK
This post has been edited by Rmclayton: 26 October 2012 - 12:05 AM

New Topic/Question
Reply



MultiQuote



|