Hello everyone,
I am trying to build a inventory and pos system with Ms-Access as database and VB 6.0 programming. I got stuck in one place again. What I want to do is trying to print out the codes and price of the products. In this form, I have a Mshflexgrid where I have three (3) columns holding the code, price and quantity of the selected products. Just for example, like
> 1. > Code Price Quantity
> 2. 20StABFtelFSS22 730 3
> 3. 20StABFPABFKA41 788.80 6
> 4. 20StABFpriUSS60 1010 9
what I want now is, a report will generate with code and price and it will be 4 Pieces. Like
> 20StABFtelFSS22 20StABFtelFSS22 20StABFtelFSS22
> $ 730.00 $ 730.00 $ 730.00
>
> 20StABFPABFKA41 20StABFPABFKA41 20StABFPABFKA41 20StABFPABFKA41 20StABFPABFKA41 20StABFPABFKA41
> $ 788.80 $ 788.80 $ 788.80 $ 788.80 $ 788.80 $ 788.80
>
> 20StABFpriUSS60 20StABFpriUSS60 20StABFpriUSS60 20StABFpriUSS60 20StABFpriUSS60 20StABFpriUSS60
> $ 1010 $ 1010 $ 1010 $ 1010 $ 1010 $ 1010
>
> 20StABFpriUSS60 20StABFpriUSS60 20StABFpriUSS60
> $ 1010 $ 1010 $ 1010
I have made a post about this previously and got the following code under the click event of my Print button:
1. Dim xQuantity As Integer, xPrint As Integer, PageNo As Integer
2. Dim strCode As String, strPrice As String
3. xQuantity = grid.TextMatrix(grid.Row, 3)
4. ''assuming that quantity is in coloumn 3...
5. strCode = grid.TextMatrix(grid.Row, 1)
6. ''assuming that Code is in coloumn 1...
7. strPrice = grid.TextMatrix(grid.Row, 2)
8. ''assuming that Price is in coloumn 2...
9. PageNo = 0
10. Line1:
11. PageNo = PageNo + 1
12. Printer.Font = "Times New Roman"
13. Printer.ScaleMode = vbCentimeters
14. Printer.Orientation = vbPRORPortrait
15. Printer.PaperSize = vbPRPSLetter
16. Printer.ScaleTop = 0
17. Printer.ScaleLeft = 0
18. Printer.FontSize = 10
19. 'Printer.Print Tab(70); "Total Quantities - "; xQuantity
20. For xPrint = 1 To xQuantity ''In this case 4
21. Select Case xQuantity
22. Case Is = 1
23. Printer.Print Tab(5); strCode
24. Printer.Print Tab(5); strPrice
25. Printer.Print Tab(5); String(55, "—")
26. Case Is = 2
27. Printer.Print Tab(5); strCode; Tab(35); strCode
28. Printer.Print Tab(5); strPrice; Tab(35); strPrice
29. Printer.Print Tab(5); String(55, "—")
30. Case Is = 3
31. Printer.Print Tab(5); strCode; Tab(35); strCode; Tab(65); strCode
32. Printer.Print Tab(5); strPrice; Tab(35); strPrice; Tab(65); strPrice
33. Printer.Print Tab(5); String(55, "—")
34. Case Is = 4
35. Printer.Print Tab(5); strCode; Tab(35); strCode; Tab(65); strCode; Tab(95); strCode
36. Printer.Print Tab(5); strPrice; Tab(35); strPrice; Tab(65); strPrice; strPrice; Tab(95); strPrice
37. Printer.Print Tab(5); String(55, "—")
38. End Select
39. Next xPrint
40. Printer.EndDoc
41. End sub
But the above code is giving me the following result:
> 20StABFtelFSS22 20StABFtelFSS22 20StABFtelFSS22
> $ 730.00 $ 730.00 $ 730.00
> 20StABFtelFSS22 20StABFtelFSS22 20StABFtelFSS22
> $ 730.00 $ 730.00 $ 730.00
> 20StABFtelFSS22 20StABFtelFSS22 20StABFtelFSS22
> $ 730.00 $ 730.00 $ 730.00
> 20StABFtelFSS22 20StABFtelFSS22 20StABFtelFSS22
> $ 730.00 $ 730.00 $ 730.00
Also this code is only printing the first row data. I know I am very novish in VB and can’t make the code working for me in the right way. What is I am missing here?
I think I make it understandable. How it is possble ? Any kinds of help will be very much appreciated. Thanks in advance.
Silversurf