943,769 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 359
  • VB.NET RSS
Mar 24th, 2009
0

Multiple column data

Expand Post »
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.
Similar Threads
Reputation Points: 178
Solved Threads: 15
Nearly a Posting Virtuoso
roryt is offline Offline
1,282 posts
since Oct 2005
Mar 24th, 2009
0

Re: Multiple column data

If you really want a response then you need to post the code you have done or tried.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,950 posts
since Aug 2005
Mar 24th, 2009
0

Re: Multiple column data

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!?

VB.NET Syntax (Toggle Plain Text)
  1. Public Class stock_control
  2. Dim con As New OleDb.OleDbConnection
  3. Dim ds As New DataSet
  4. Dim da As OleDb.OleDbDataAdapter
  5. Dim sql As String
  6. Dim rnum As Single = 0
  7. Private Sub stock_control_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  8. con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = D:\computing_db_work\Signature Solutions Ltd Shop system\rory_stock.mdb"
  9.  
  10. con.Open()
  11.  
  12. sql = "SELECT * FROM products"
  13. da = New OleDb.OleDbDataAdapter(sql, con)
  14.  
  15. 'MsgBox("Connection to Database opened")
  16.  
  17. da.Fill(ds, "products")
  18.  
  19. con.Close()
  20.  
  21. 'MsgBox("Dataset filled")
  22.  
  23.  
  24. 'IN STRING!
  25. Dim tab
  26. Dim txt, txt2, txt3
  27. Dim length, Length2, Length3, Length4 As Single
  28. rnum = 0
  29. While ds.Tables("products").Rows(rnum).Item(0) < 1290
  30. txt = ds.Tables("products").Rows(rnum).Item(4)
  31. length = (Len(txt))
  32. txt2 = ds.Tables("products").Rows(rnum).Item(5)
  33. Length2 = (Len(txt2))
  34. txt3 = ds.Tables("products").Rows(rnum).Item(6)
  35. Length3 = (Len(txt3))
  36. Length4 = Length3 + Length2 + length
  37. ds.Tables("products").Rows(rnum).Item(27) = Length4
  38. rnum = rnum + 1
  39.  
  40. 'If Length4 = 16 Then
  41. '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))
  42. 'End If
  43. End While
  44.  
  45. 'MsgBox("Finished")
  46. rnum = 0
  47.  
  48.  
  49.  
  50. While ds.Tables("products").Rows(rnum).Item(0) < 1290
  51.  
  52. If ds.Tables("products").Rows(rnum).Item(27) < 16 Then
  53. tab = vbTab & vbTab & vbTab & vbTab & vbTab
  54. ElseIf ds.Tables("products").Rows(rnum).Item(27) < 17 Then
  55. tab = vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab
  56. ElseIf ds.Tables("products").Rows(rnum).Item(27) < 18 Then
  57. tab = vbTab & vbTab & vbTab & vbTab & vbTab
  58. ElseIf ds.Tables("products").Rows(rnum).Item(27) < 19 Then
  59. tab = vbTab & vbTab & vbTab & vbTab & vbTab & vbTab
  60. ElseIf ds.Tables("products").Rows(rnum).Item(27) < 20 Then
  61. tab = vbTab & vbTab & vbTab & vbTab & vbTab & vbTab
  62. ElseIf ds.Tables("products").Rows(rnum).Item(27) < 21 Then
  63. tab = vbTab & vbTab & vbTab & vbTab & vbTab
  64. ElseIf ds.Tables("products").Rows(rnum).Item(27) < 22 Then
  65. tab = vbTab & vbTab & vbTab & vbTab & vbTab
  66. ElseIf ds.Tables("products").Rows(rnum).Item(27) < 23 Then
  67. tab = vbTab & vbTab & vbTab & vbTab & vbTab & vbTab
  68. ElseIf ds.Tables("products").Rows(rnum).Item(27) < 24 Then
  69. tab = vbTab & vbTab & vbTab & vbTab
  70. ElseIf ds.Tables("products").Rows(rnum).Item(27) < 25 Then
  71. tab = vbTab & vbTab & vbTab & vbTab & vbTab & vbTab
  72. ElseIf ds.Tables("products").Rows(rnum).Item(27) < 26 Then
  73. tab = vbTab & vbTab
  74. ElseIf ds.Tables("products").Rows(rnum).Item(27) < 27 Then
  75. tab = vbTab & vbTab & vbTab & vbTab & vbTab & vbTab
  76. ElseIf ds.Tables("products").Rows(rnum).Item(27) < 28 Then
  77. tab = vbTab & vbTab & vbTab
  78. ElseIf ds.Tables("products").Rows(rnum).Item(27) < 29 Then
  79. tab = vbTab & vbTab & vbTab & vbTab
  80. ElseIf ds.Tables("products").Rows(rnum).Item(27) < 30 Then
  81. tab = vbTab & vbTab & vbTab & vbTab
  82. ElseIf ds.Tables("products").Rows(rnum).Item(27) < 31 Then
  83. tab = vbTab & vbTab & vbTab & vbTab
  84. ElseIf ds.Tables("products").Rows(rnum).Item(27) < 32 Then
  85. tab = vbTab & vbTab & vbTab & vbTab
  86. ElseIf ds.Tables("products").Rows(rnum).Item(27) < 33 Then
  87. tab = vbTab
  88. ElseIf ds.Tables("products").Rows(rnum).Item(27) < 34 Then
  89. tab = vbTab & vbTab & vbTab & vbTab
  90. ElseIf ds.Tables("products").Rows(rnum).Item(27) < 35 Then
  91. tab = vbTab & vbTab & vbTab
  92. ElseIf ds.Tables("products").Rows(rnum).Item(27) < 36 Then
  93. tab = vbTab & vbTab & vbTab
  94. ElseIf ds.Tables("products").Rows(rnum).Item(27) < 37 Then
  95. tab = vbTab & vbTab
  96. ElseIf ds.Tables("products").Rows(rnum).Item(27) < 38 Then
  97. tab = vbTab & vbTab
  98. ElseIf ds.Tables("products").Rows(rnum).Item(27) < 39 Then
  99. tab = vbTab & vbTab
  100. ElseIf ds.Tables("products").Rows(rnum).Item(27) < 40 Then
  101. tab = vbTab & vbTab
  102. ElseIf ds.Tables("products").Rows(rnum).Item(27) < 41 Then
  103. tab = vbTab & vbTab
  104. ElseIf ds.Tables("products").Rows(rnum).Item(27) < 42 Then
  105. tab = vbTab & vbTab
  106. ElseIf ds.Tables("products").Rows(rnum).Item(27) < 43 Then
  107. tab = vbTab & vbTab
  108. ElseIf ds.Tables("products").Rows(rnum).Item(27) < 44 Then
  109. tab = vbTab & vbTab
  110. End If
  111.  
  112. 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))
  113. rnum = rnum + 1
  114. tab = ""
  115. End While
  116.  
  117.  
  118. End Sub
Reputation Points: 178
Solved Threads: 15
Nearly a Posting Virtuoso
roryt is offline Offline
1,282 posts
since Oct 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Deleting record from mutiple tables
Next Thread in VB.NET Forum Timeline: How to inherit windows form that contain controls





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC