Multiple column data

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2005
Posts: 1,283
Reputation: roryt will become famous soon enough roryt will become famous soon enough 
Solved Threads: 14
roryt's Avatar
roryt roryt is offline Offline
Nearly a Posting Virtuoso

Multiple column data

 
0
  #1
Mar 24th, 2009
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.
PhotoShopthis
FlyingPen
If I have helped you please add to my reputation
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,362
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1464
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: Multiple column data

 
0
  #2
Mar 24th, 2009
If you really want a response then you need to post the code you have done or tried.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Oct 2005
Posts: 1,283
Reputation: roryt will become famous soon enough roryt will become famous soon enough 
Solved Threads: 14
roryt's Avatar
roryt roryt is offline Offline
Nearly a Posting Virtuoso

Re: Multiple column data

 
0
  #3
Mar 24th, 2009
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!?

  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
PhotoShopthis
FlyingPen
If I have helped you please add to my reputation
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC