View Single Post
 
Old 12-14-2014, 11:39 AM
Inlee Inlee is offline
Newcomer
 
Join Date: Dec 2014
Posts: 1
Default Saving a Listbox orr adding a list box to a text file

Ok, I have been struggling with this for about a month now, have searched for the help could not find it. Maybe I am just not understanding it. I will post here what I have and what I am trying to accomplish and see if anyone has any suggestions on a direction to try.

I have a Listbox that takes all of the information from several textboxs and combines it into said listbox. From there I need to save that listbox into a text file and/or have it all transfer into a textbox so I can save it. I have my textbox set to save, works like it is supposed to so no problem there, just a matter of, for lack of better words, making the listbox copy itself to the textbox so I can save it.

listbox1 = lbxLoad
textbox1.text = txtLoad.Text

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInfo.Click
lbxLoad.Items.Add("[Load Information]")
lbxLoad.Items.Add("*************************************************** ********************")
lbxLoad.Items.Add(" ")
lbxLoad.Items.Add("Load Number: " & vbTab & txtLoadNumber.Text)
lbxLoad.Items.Add("*************************************************** ********************")
lbxLoad.Items.Add(" ")
lbxLoad.Items.Add("[Pickup Information] ")
lbxLoad.Items.Add("*************************************************** ********************")
lbxLoad.Items.Add("Pickup Date: " & vbTab & DateTimePicker1.Text)
lbxLoad.Items.Add("*************************************************** ********************")
lbxLoad.Items.Add("Shipper: " & vbTab & vbTab & txtShipper.Text)
lbxLoad.Items.Add("Address: " & vbTab & vbTab & txtShipperAddress.Text)
lbxLoad.Items.Add("City: " & vbTab & vbTab & txtShipperCity.Text)
lbxLoad.Items.Add("State: " & vbTab & vbTab & cmbShipperState.Text)
lbxLoad.Items.Add("Phone: " & vbTab & vbTab & mtbShipperPhone.Text)
lbxLoad.Items.Add("*************************************************** ********************")
lbxLoad.Items.Add(" ")
lbxLoad.Items.Add("[Delivery Information] ")
lbxLoad.Items.Add("*************************************************** ********************")
lbxLoad.Items.Add("Delivery Date: " & vbTab & DateTimePicker2.Text)
lbxLoad.Items.Add("*************************************************** ********************")
lbxLoad.Items.Add("Receiver: " & vbTab & txtReceiver.Text)
lbxLoad.Items.Add("Address: " & vbTab & vbTab & txtReceiverAddress.Text)
lbxLoad.Items.Add("City: " & vbTab & vbTab & txtReceiverCity.Text)
lbxLoad.Items.Add("State: " & vbTab & vbTab & cmbReceiverState.Text)
lbxLoad.Items.Add("Phone: " & vbTab & vbTab & mtbReceiverPhone.Text)
lbxLoad.Items.Add("*************************************************** ********************")
lbxLoad.Items.Add(" ")
lbxLoad.Items.Add("[Mileage Information] ")
lbxLoad.Items.Add("*************************************************** ********************")
lbxLoad.Items.Add("Starting Mileage: " & vbTab & txtStartMileage.Text)
lbxLoad.Items.Add("Ending Mileage: " & vbTab & txtEndMileage.Text)
lbxLoad.Items.Add("Empty Miles: " & vbTab & txtEmptyMiles.Text)
lbxLoad.Items.Add("Loaded Miles: " & vbTab & txtLoadedMiles.Text)
lbxLoad.Items.Add("Total Miles: " & vbTab & txtTotalMiles.Text)
lbxLoad.Items.Add("*************************************************** ********************")
lbxLoad.Items.Add(" ")
lbxLoad.Items.Add("[Pay Information] ")
lbxLoad.Items.Add("*************************************************** ********************")
lbxLoad.Items.Add("Base Rate: " & vbTab & vbTab & "$" & txtBasePay.Text)
lbxLoad.Items.Add("Miles at Base Rate:" & vbTab & vbTab & "$" & txtTotalBase.Text)
lbxLoad.Items.Add("Per Diem Rate: " & vbTab & vbTab & "$" & txtPerDiemPay.Text)
lbxLoad.Items.Add("Miles at Per Diem rate:" & vbTab & "$" & txtTotalPerDiem.Text)
lbxLoad.Items.Add("Detention: " & vbTab & vbTab & "$" & txtTotalDetention.Text)
lbxLoad.Items.Add("Stops: " & vbTab & vbTab & vbTab & "$" & txtTotalStops.Text)
lbxLoad.Items.Add("Advances: " & vbTab & vbTab & "$" & txtTotalAdvances.Text)
lbxLoad.Items.Add("Total pay for trip: " & vbTab & vbTab & "$" & txtTotalPay.Text)

If lbxLoad.SelectedItems.Count = 1 Then
txtLoad.Text = lbxLoad.SelectedItem
End If
End Sub

All of the information in lbxLoad needs to be transferred to txtLoad.text preferably with the simple press of a button. Any suggestions?

I am willing to send more of the code and or the program itself if more information is needed, just ask.
Reply With Quote