Ok, so....on a whim I've decided to write a trivial program to organize Wal-Mart shopping trips. A simple program yet effective I think. The problem I've hit is that I can't find anywhere a way in which I can do custom ordering on a ListBox. The only way to order that I know of is alphabetically. Basically, what I want to do is have a list of items you could select and then based on their location in the store, sort them in the list that I can then print out. This will effectively make store trips more efficient so that you can make a round trip through the store and not miss any items and have to go back and get more.
Here's what I have so far.....
CODE
Public Class Form1
Private Sub ListBox1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.DoubleClick
ListBox2.Items.Add(ListBox1.SelectedItem)
ListBox1.Items.Remove(ListBox1.SelectedItem)
End Sub
Private Sub ListBox2_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox2.DoubleClick
ListBox1.Items.Add(ListBox2.SelectedItem)
ListBox2.Items.Remove(ListBox2.SelectedItem)
End Sub
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
Dim shopItems As Integer = ListBox2.Items.Count
Dim items As String = ""
For i As Integer = 0 To shopItems - 1
items &= ListBox2.Items.Item(i).ToString & vbCrLf
Next
If Not IO.File.Exists("C:\" & Today.Month & "-" & Today.Day & "-" & Today.Year & ".txt") Then
IO.File.WriteAllText("C:\" & Today.Month & "-" & Today.Day & "-" & Today.Year & ".txt", items)
Else
MsgBox("File already exists!")
' Plan to change this around later
End If
End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub
End Class
I figured the easiest way would be to sort the items in the list and then just shoot them out into a file. If it's not possible to do a custom re-ordering, I'll have to figure out some kind of logic to reorder as I'm streaming the items into the string to output to the file (if anyone has a suggestion on that route, I'd appreciate it as well). Thanks for your time. Peace, love, and chicken grease.