:( hi people i nid help in calculating an item from a texfile that exists from menu_cmbselectedIndex,i want to display total number of items when i click a combobox and should also display total amount for those items,pls respond A.S.A.P

More detail please.

What is menu_cmbselectedIndex? A menu, a combobox, or a combobox.selectedIndex property? What does it hold and where is this textfile?

Give us some code that you've already attempted to put together.

Giving it a shot.

If your text file displays as the following:

price: $10/total items in stock: 100
price: $20/total items in stock: 200
price: $30/total items in stock: 300
price: $40/total items in stock: 400
price: $50/total items in stock: 500

The following code will read a line from the file depending on which index is selected in the "Combobox".

Public Class Form1

    Private myFile() As String = IO.File.ReadAllLines("C:\test.txt") '// load file into an array.

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        With ComboBox1.Items
            .Add("Item 1") : .Add("Item 2") : .Add("Item 3") : .Add("Item 4") : .Add("Item 5")
        End With
    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        Dim txtLine As Integer = ComboBox1.SelectedIndex '// get index for which line to read.
        Dim myArray() As String = myFile(txtLine).Split("/") '// split line into strings.
        MsgBox(myArray(0), MsgBoxStyle.Information) '// display first string in myArray.
        MsgBox(myArray(1), MsgBoxStyle.Information) '// display second string in myArray.
    End Sub
End Class

As the_carpenter stated, more details will be beneficial for those replying and for you, the original poster.

Otherwise, I hope the above project sample helps.

This article has been dead for over six months. Start a new discussion instead.