This problem is causing me a massive headache! I'm sure I can't be the first person to do this but I have searched the internet high and low for answers about this.

I want to be able to display in a list as seperate fields:
- A product name
- Quantity on hand
- Price

It will display a long list of a couple of thousand but i would like the columns of each to line up. There must be a simple way to do this?

I am taking the data from a dataset which is reading from a access database using sql.

I would really really appreciate a reply. Thank you in advance.

If you really want a response then you need to post the code you have done or tried.

This is my code. I realise there are far better ways of doing some of the things, but at the moment it is just how the logic has come out of my brain!

It should make some sense, but all the vbtab stuff is (i think) pointless coding because there must be another way of doing this!?

Public Class stock_control
    Dim con As New OleDb.OleDbConnection
    Dim ds As New DataSet
    Dim da As OleDb.OleDbDataAdapter
    Dim sql As String
    Dim rnum As Single = 0
    Private Sub stock_control_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = D:\computing_db_work\Signature Solutions Ltd Shop system\rory_stock.mdb"

        con.Open()

        sql = "SELECT * FROM products"
        da = New OleDb.OleDbDataAdapter(sql, con)

        'MsgBox("Connection to Database opened")

        da.Fill(ds, "products")

        con.Close()

        'MsgBox("Dataset filled")


        'IN STRING!
        Dim tab
        Dim txt, txt2, txt3
        Dim length, Length2, Length3, Length4 As Single
        rnum = 0
        While ds.Tables("products").Rows(rnum).Item(0) < 1290
            txt = ds.Tables("products").Rows(rnum).Item(4)
            length = (Len(txt))
            txt2 = ds.Tables("products").Rows(rnum).Item(5)
            Length2 = (Len(txt2))
            txt3 = ds.Tables("products").Rows(rnum).Item(6)
            Length3 = (Len(txt3))
            Length4 = Length3 + Length2 + length
            ds.Tables("products").Rows(rnum).Item(27) = Length4
            rnum = rnum + 1

            'If Length4 = 16 Then
            'MsgBox(ds.Tables("products").Rows(rnum).Item(5) & " " & ds.Tables("products").Rows(rnum).Item(4) & " " & ds.Tables("products").Rows(rnum).Item(6) & tab & ds.Tables("products").Rows(rnum).Item(26) & vbTab & ds.Tables("products").Rows(rnum).Item(11))
            'End If
        End While

        'MsgBox("Finished")
        rnum = 0



        While ds.Tables("products").Rows(rnum).Item(0) < 1290

            If ds.Tables("products").Rows(rnum).Item(27) < 16 Then
                tab = vbTab & vbTab & vbTab & vbTab & vbTab
            ElseIf ds.Tables("products").Rows(rnum).Item(27) < 17 Then
                tab = vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab
            ElseIf ds.Tables("products").Rows(rnum).Item(27) < 18 Then
                tab = vbTab & vbTab & vbTab & vbTab & vbTab
            ElseIf ds.Tables("products").Rows(rnum).Item(27) < 19 Then
                tab = vbTab & vbTab & vbTab & vbTab & vbTab & vbTab
            ElseIf ds.Tables("products").Rows(rnum).Item(27) < 20 Then
                tab = vbTab & vbTab & vbTab & vbTab & vbTab & vbTab
            ElseIf ds.Tables("products").Rows(rnum).Item(27) < 21 Then
                tab = vbTab & vbTab & vbTab & vbTab & vbTab
            ElseIf ds.Tables("products").Rows(rnum).Item(27) < 22 Then
                tab = vbTab & vbTab & vbTab & vbTab & vbTab
            ElseIf ds.Tables("products").Rows(rnum).Item(27) < 23 Then
                tab = vbTab & vbTab & vbTab & vbTab & vbTab & vbTab
            ElseIf ds.Tables("products").Rows(rnum).Item(27) < 24 Then
                tab = vbTab & vbTab & vbTab & vbTab
            ElseIf ds.Tables("products").Rows(rnum).Item(27) < 25 Then
                tab = vbTab & vbTab & vbTab & vbTab & vbTab & vbTab
            ElseIf ds.Tables("products").Rows(rnum).Item(27) < 26 Then
                tab = vbTab & vbTab
            ElseIf ds.Tables("products").Rows(rnum).Item(27) < 27 Then
                tab = vbTab & vbTab & vbTab & vbTab & vbTab & vbTab
            ElseIf ds.Tables("products").Rows(rnum).Item(27) < 28 Then
                tab = vbTab & vbTab & vbTab
            ElseIf ds.Tables("products").Rows(rnum).Item(27) < 29 Then
                tab = vbTab & vbTab & vbTab & vbTab
            ElseIf ds.Tables("products").Rows(rnum).Item(27) < 30 Then
                tab = vbTab & vbTab & vbTab & vbTab
            ElseIf ds.Tables("products").Rows(rnum).Item(27) < 31 Then
                tab = vbTab & vbTab & vbTab & vbTab
            ElseIf ds.Tables("products").Rows(rnum).Item(27) < 32 Then
                tab = vbTab & vbTab & vbTab & vbTab
            ElseIf ds.Tables("products").Rows(rnum).Item(27) < 33 Then
                tab = vbTab
            ElseIf ds.Tables("products").Rows(rnum).Item(27) < 34 Then
                tab = vbTab & vbTab & vbTab & vbTab
            ElseIf ds.Tables("products").Rows(rnum).Item(27) < 35 Then
                tab = vbTab & vbTab & vbTab
            ElseIf ds.Tables("products").Rows(rnum).Item(27) < 36 Then
                tab = vbTab & vbTab & vbTab
            ElseIf ds.Tables("products").Rows(rnum).Item(27) < 37 Then
                tab = vbTab & vbTab
            ElseIf ds.Tables("products").Rows(rnum).Item(27) < 38 Then
                tab = vbTab & vbTab
            ElseIf ds.Tables("products").Rows(rnum).Item(27) < 39 Then
                tab = vbTab & vbTab
            ElseIf ds.Tables("products").Rows(rnum).Item(27) < 40 Then
                tab = vbTab & vbTab
            ElseIf ds.Tables("products").Rows(rnum).Item(27) < 41 Then
                tab = vbTab & vbTab
            ElseIf ds.Tables("products").Rows(rnum).Item(27) < 42 Then
                tab = vbTab & vbTab
            ElseIf ds.Tables("products").Rows(rnum).Item(27) < 43 Then
                tab = vbTab & vbTab
            ElseIf ds.Tables("products").Rows(rnum).Item(27) < 44 Then
                tab = vbTab & vbTab
            End If

            lb_stock.Items.Add(ds.Tables("products").Rows(rnum).Item(5) & " " & ds.Tables("products").Rows(rnum).Item(4) & " " & ds.Tables("products").Rows(rnum).Item(6) & tab & ds.Tables("products").Rows(rnum).Item(26) & vbTab & ds.Tables("products").Rows(rnum).Item(11))
            rnum = rnum + 1
            tab = ""
        End While


    End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.