jeepgirl

I'm trying to figure out how to choose a item from the listbox and display the price in the textbox

Thanks



Re: Visual Basic Express Edition Help listing price from ListBox into txtbox

Jay Vora

see i hv given the code for listbox items from database..try this..

Imports System.Data.OleDb

Public Class Form1

Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()

MyBase.New()

'This call is required by the Windows Form Designer.

InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

If disposing Then

If Not (components Is Nothing) Then

components.Dispose()

End If

End If

MyBase.Dispose(disposing)

End Sub

'Required by the Windows Form Designer

Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer

'It can be modified using the Windows Form Designer.

'Do not modify it using the code editor.

Friend WithEvents ListBox1 As System.Windows.Forms.ListBox

Friend WithEvents TextBox1 As System.Windows.Forms.TextBox

Friend WithEvents Button1 As System.Windows.Forms.Button

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

Me.ListBox1 = New System.Windows.Forms.ListBox

Me.TextBox1 = New System.Windows.Forms.TextBox

Me.Button1 = New System.Windows.Forms.Button

Me.SuspendLayout()

'

'ListBox1

'

Me.ListBox1.Location = New System.Drawing.Point(48, 8)

Me.ListBox1.Name = "ListBox1"

Me.ListBox1.Size = New System.Drawing.Size(136, 56)

Me.ListBox1.TabIndex = 0

'

'TextBox1

'

Me.TextBox1.Location = New System.Drawing.Point(56, 160)

Me.TextBox1.Name = "TextBox1"

Me.TextBox1.Size = New System.Drawing.Size(136, 20)

Me.TextBox1.TabIndex = 1

Me.TextBox1.Text = ""

'

'Button1

'

Me.Button1.Location = New System.Drawing.Point(120, 96)

Me.Button1.Name = "Button1"

Me.Button1.Size = New System.Drawing.Size(88, 24)

Me.Button1.TabIndex = 2

Me.Button1.Text = "Button1"

'

'Form1

'

Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)

Me.ClientSize = New System.Drawing.Size(292, 266)

Me.Controls.Add(Me.Button1)

Me.Controls.Add(Me.TextBox1)

Me.Controls.Add(Me.ListBox1)

Me.Name = "Form1"

Me.Text = "Form1"

Me.ResumeLayout(False)

End Sub

#End Region

'con.ConnectionString = New OleDb.OleDbConnection(" Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D://db1.mdb")

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim strText

strText = ListBox1.SelectedItem

TextBox1.Text = strText

End Sub

Dim con As New OleDb.OleDbConnection

Dim ConnectionString As String

Dim da As New OleDb.OleDbDataAdapter

Dim cmd As OleDb.OleDbCommand

Dim query As String

Dim ds As DataSet

Dim dt As DataTable

Public Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim i As Integer

Dim j As Integer

Dim k As Integer

k = 0

Dim ds As New DataSet

con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D://db1.mdb"

con = New OleDbConnection(con.ConnectionString)

con.Open()

da = New OleDb.OleDbDataAdapter("select * from table1", con)

da.Fill(ds)

dt = ds.Tables(0)

Dim dc As DataColumn

dc = dt.Columns(0)

Try

For i = 0 To 2 Step 1

For j = 0 To 2 Step 1

ListBox1.Items.Insert(k, dt.Rows(j).Item(i))

k = k + 1

Next

Next

Catch ex As Exception

MsgBox(ex.ToString)

End Try

End Sub

Private Sub form1_unload()

con.Close()

End Sub

End Class






Re: Visual Basic Express Edition Help listing price from ListBox into txtbox

GlennZarb

Where is the price saved In the listbox or somewhere else like a database




Re: Visual Basic Express Edition Help listing price from ListBox into txtbox

mellie430

in an array i guess



Re: Visual Basic Express Edition Help listing price from ListBox into txtbox

mellie430

Thanks, I figured out through your code...



Re: Visual Basic Express Edition Help listing price from ListBox into txtbox

Jay Vora

thx...