Current location: Hot Scripts Forums » Programming Languages » Windows .NET Programming » Saving Listbox Selections


Saving Listbox Selections

Reply
  #1 (permalink)  
Old 08-09-04, 01:44 PM
Trigger Trigger is offline
New Member
 
Join Date: Aug 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Wink Saving Listbox Selections

A program I am working on has a series of listboxes. When I close the program down I wish to save the selections so that the next time I start the program up the selections are still in place. Please tell me how to do this so I can stop chasing my tail.
Reply With Quote
  #2 (permalink)  
Old 08-20-04, 05:54 PM
digioz's Avatar
digioz digioz is offline
Community VIP
 
Join Date: Oct 2003
Location: Chicago, IL
Posts: 2,171
Thanks: 3
Thanked 9 Times in 9 Posts
Hi,


I have a filestream example that would help you out further. Here is the code I used in it:

Code:
 
 
Private Sub btnReadFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click, btnReadFile.Click

		Const BLOCK_SIZE As Integer = 100
		Dim FileToOpen As String
		OpenFileDialog1.ShowDialog()
		txtPathToFile.Text = OpenFileDialog1.FileName

		Dim TestFile As BinaryReader
		Dim BytesRead As Integer
		Dim ByteValues(BLOCK_SIZE) As Byte
		Dim StringValue As String
		Dim ASCIIConverter As System.Text.ASCIIEncoding
		Dim FilePath As String

		txtMessage.Text = ""
		' FilePath = Application.StartupPath & "\..\quotes.txt"
		FilePath = txtPathToFile.Text
		If Not File.Exists(FilePath) Then
			MessageBox.Show("Cannot find file " & FilePath)
			Exit Sub
		End If

		'Open a File for Reading
		TestFile = New BinaryReader(File.Open(FilePath, IO.FileMode.Open, IO.FileAccess.Read))
	 
		'Read the file in byte blocks and build a string
		BytesRead = TestFile.Read(ByteValues, 0, BLOCK_SIZE)
		ASCIIConverter = New System.Text.ASCIIEncoding()
		While BytesRead > 0
			StringValue = ASCIIConverter.GetString(ByteValues, 0, BytesRead)
			txtMessage.Text &= StringValue
			Array.Clear(ByteValues, 0, BLOCK_SIZE)
			BytesRead = TestFile.Read(ByteValues, 0, BLOCK_SIZE)
		End While

		'Display the resulting string in a text box

		TestFile.Close()
	End Sub

Here are all the source code to this script:

http://www.digioz.com/devry/CIS430/Lab/filestream/

And here is a working executable program of it. You will need to have the ".NET" platform installed on your computer to be able to run it. Here is the link to that:

http://www.digioz.com/devry/CIS430/L...FileStream.exe
__________________
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
saving data with PHP form sXenoGJ PHP 4 04-30-04 11:25 PM
listbox prob! tadpole Windows .NET Programming 2 02-17-04 06:51 AM
Help with saving a page (XMLHTTP?) ziadn JavaScript 0 01-15-04 01:38 AM
Saving changes made by a javascript to the server Leanne JavaScript 7 01-08-04 11:57 AM
$_POST[] and multiple selections odafeelin PHP 5 12-24-03 08:43 PM


All times are GMT -5. The time now is 02:14 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.