list box

list box loads item id and item price

Page 1 of 1

4 Replies - 1671 Views - Last Post: 24 November 2008 - 02:23 PM Rate Topic: -----

#1 fire3000  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 22-November 08

list box

Post icon  Posted 23 November 2008 - 05:11 PM

Option Explicit On
Option Strict On

Public Class MainForm

	Structure Product
		Public id As String
		Public price As Decimal

	End Structure

	Private Sub xExitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles xExitButton.Click
		Me.Close()
	End Sub
	Private Sub xNumbersListBox_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles xNumbersListBox.Click
		'displays price associated with the product ID click by the user

		Dim searchFor As String
		Dim subscript As Integer
		Dim item(4) As Product
		'assign array  

		item(0).id = "12AVX"
		item(0).price = CDec(5)
		item(1).id = "23ABC"
		item(1).price = CDec(8.97)
		item(2).id = "23TWT"
		item(2).price = CDec(4.69)
		item(3).id = "34ZAB"
		item(3).price = CDec(12.5)
		item(4).id = "91BAN"
		item(4).price = CDec(34.67)

		searchFor = Me.xNumbersListBox.Text
		Do Until subscript = item.Length _
			OrElse searchFor = item(subscript).id
			subscript = subscript + 1
		Loop
		If subscript < item.Length Then
			Me.xPriceLabel.Text = _
			item(subscript).price.ToString("C0")
		End If
	End Sub

	Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
		Const itemInfo As String = "itemInfo.txt"
		Dim item As String
		Dim name As String
		Dim newLineIndex As Integer
		Dim newIndex As Integer

		If My.Computer.FileSystem.FileExists(itemInfo) Then
			item = My.Computer.FileSystem.ReadAllText(itemInfo)
			newLineIndex = item.IndexOf(ControlChars.NewLine)

			Do Until newLineIndex = -1
				name = _
					item.Substring(newIndex, newLineIndex - newIndex)
				Me.xNumbersListBox.Items.Add(name)
				newIndex = newLineIndex + 2
				newLineIndex = _
					item.IndexOf(ControlChars.NewLine, newIndex)
			Loop
		End If
	End Sub
End Class



how do i stop the price from loading??

Is This A Good Question/Topic? 0
  • +

Replies To: list box

#2 thava  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 180
  • View blog
  • Posts: 1,606
  • Joined: 17-April 07

Re: list box

Posted 23 November 2008 - 07:05 PM

did you search in the .net section
Was This Post Helpful? 0
  • +
  • -

#3 fire3000  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 22-November 08

Re: list box

Posted 23 November 2008 - 07:53 PM

View Postthava, on 23 Nov, 2008 - 06:05 PM, said:

did you search in the .net section

yes but it dosnt show how remove characters it from string
Was This Post Helpful? 0
  • +
  • -

#4 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1639
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: list box

Posted 23 November 2008 - 08:06 PM

Moved to VB.NET :)
Was This Post Helpful? 0
  • +
  • -

#5 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: list box

Posted 24 November 2008 - 02:23 PM

I am a little confused on what you are asking. Can you describe in detail where you are having problems?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1