473,387 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to display an arrays' contents into a listbox?

Option Strict On
Public Class frmBookPublishing

' Class Level Private Variables
Private Shared _intSizeOfArray As Integer = 16
Private Shared _strWarehouseItem(_intSizeOfArray) As String
Private _decBookPrice(_intSizeOfArray) As Decimal
Private _intBooksOnHand(_intSizeOfArray) As Integer
Private _intBooksOrdered(_intSizeOfArray) As Integer

Private Sub frmBookPublishing_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' The frmBookPublishing load event reads the warehouse text file and fills the ListBox object
' with the warehouse items.
' Initialize an instance of the Streamreader object and declare variables.
Dim objReader As IO.StreamReader
Dim strLocationAndNameofFile As String = "C:\Users\Stacey\Documents\Visual Studio 2008\Projects\FlicksBookPublishing\FlicksBookPubli shing\File\warehouse.txt"
Dim intCount As Integer = 0
Dim strFileError As String = "The file is not available. Restart when the file is available."
' Verify the file exists
If IO.File.Exists(strLocationAndNameofFile) Then
objReader = IO.File.OpenText(strLocationAndNameofFile)
'Read the file line by line until the file is completed
Do While objReader.Peek <> -1
_strWarehouseItem(intCount) = objReader.ReadLine()
_decBookPrice(intCount) = Convert.ToDecimal(objReader.ReadLine())
_intBooksOnHand(intCount) = Convert.ToInt32(objReader.ReadLine())
intCount += 1
_intBooksOrdered(intCount) = Convert.ToInt32(objReader.ReadLine())
intCount += 1
Loop
objReader.Close()

' Display the Names of the Books
For intFill = 0 To (_strWarehouseItem.Length - 1)
Me.lstBookTitles.Items.Add(_strWarehouseItem(intFi ll))
Next
Else
MsgBox(strFileError, , "Error")
Me.Close()
End If
End Sub
Nov 29 '10 #1
0 1214

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Tony W. | last post by:
I am trying to do something in PHP that I thought would be fairly easy but has become rather troublesome. I'm trying to retrieve a list of numbers from a MySQL database and display the contents...
1
by: Seth Delaney | last post by:
I have a form with a combobox and a list box. The combobox will list records (names of queries) that are entered in a table called tblListName. I have the combobox set to get its values from this...
4
by: Hardy Wang | last post by:
Hi I have a ListBox control in my ASP.NET page. After I binding data to this control, I would like to be able to change this display order of items in this control. Just like change layout...
0
by: **Developer** | last post by:
How can I display the contents of My Network Places and a shared folder in it? Thanks
4
by: Arif | last post by:
how to display combobox contents(the same function that occurs when Mouse is pressed on a combobox but) on MouseEnter/MouseHover events? arif.
1
by: NBB | last post by:
I can't figure this one out. Here's the situation, should be pretty for the pros in here. I have a ListBox that is populated with the DataTextField and DataValueField flags of the DataSet....
9
by: Paul H | last post by:
I have developed several databases in Access. I know VBA. I am making the jump to VB and am currently using Visual basic 2005 Express. Can anyone give me a snippet that will show me how to list...
1
by: dearprasan | last post by:
I have a custom browser application built in C#. I want to access the Internet Explorer's Cache to display contents on this custom browser application. For example: If the user types "www.msn.com"...
2
by: Plumebee | last post by:
Hi, I am very new to programming and have just started to use Visual Basic 2005 Express Edition. I am trying to read from a text file to draw a rectangles and lines. However to begin I'm trying to...
10
by: sarega | last post by:
Here is the situation there is a list of contents from which the user can select the required contents to be displayed, but below these list of contents, the contents are actually displayed in the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.