I am fairly new to vb.net and was wanting to make a bubble sort from this information. From searching the net I found some but still do not understand how to do it with what I have.
Here is all of the code that I have and guidance on where to start to do a bubble sort ? I have a menu with each of the structure names in it and would like to be able to sort the array when it is displayed by each of those elements.Am I missing something with the structure to be able to do this?
Here is all of the code that I have and guidance on where to start to do a bubble sort ? I have a menu with each of the structure names in it and would like to be able to sort the array when it is displayed by each of those elements.Am I missing something with the structure to be able to do this?
VB.NET:
Structure MovieInfo
<VBFixedString(20)> Public Title As String
<VBFixedString(4)> Public Year As Integer
<VBFixedString(4)> Public Price As Integer
Public sngPrice As Single
End Structure
Public udtMovie As MovieInfo
Public objMovieArray(0) As Object
Private Sub btnAddMovie_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddMovie.Click
Try
udtMovie.Title = txtTitle.Text
udtMovie.Year = txtYear.Text
udtMovie.Price = txtPrice.Text
udtMovie.sngPrice = Val(txtPrice.Text)
Dim intSize As Integer
intSize = UBound(objMovieArray)
ReDim Preserve objMovieArray(intSize + 1)
objMovieArray(intSize) = udtMovie.Title & vbTab & udtMovie.Year & vbTab & udtMovie.sngPrice
MsgBox("The Following Movie was added to array:" & vbCrLf & objMovieArray(intSize), MsgBoxStyle.Information, "Record added")
'btnViewArray.Enabled = True
txtTitle.Clear()
txtYear.Clear()
txtPrice.Clear()
Catch ex As Exception
MsgBox("Error occured in application", MsgBoxStyle.Critical)
End Try
End Sub
Private Sub btnViewArray_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnViewArray.Click
Try
Dim intCounter As Integer
Dim intSize As Integer
intSize = UBound(objMovieArray) - 1
lstArray.Items.Clear()
For intCounter = 0 To intSize
lstArray.Items.Add(objMovieArray(intCounter))
Next intCounter
Catch ex As Exception
MsgBox("Error occuried while trying to view the array", MsgBoxStyle.Critical)
End Try
End Sub
Last edited by a moderator: