CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2011
    Posts
    19

    VB6 - Help With Multiple Selections Combo Boxes Or Text Boxes ?

    Hi !

    This time, I have a simple question but I am confused with it.

    I am developing an application for my printing business in which I would be keeping record of all the orders. I have divided it into two parts i.e. One part is for Screen Printing Orders and One for Offset Printing Orders. I have completed the first one and working on second part.

    In this part, I need to record the details of printing orders which includes Job Title (that could be Invoice Books, Receipt Books etc), its Size, Qty, No of Bills/Receipts, No of carbon copies, No. of colours, Quality of paper etc.

    Invoice Books can be in Duplicate (1+1), Triplicate (1+2), Quadruplicate (1+3) upto the maximum of of 1+5. Every page can have maximum of two colours.

    I have placed 6 combo boxes in the following manner :

    Paper Colour1 ------ Paper Quality1 ------ Paper1 Colour 1 ------ Paper1 Colour 2
    Paper Colour2 ------ Paper Quality2 ------ Paper2 Colour 1 ------ Paper2 Colour 2
    Paper Colour3 ------ Paper Quality3 ------ Paper3 Colour 1 ------ Paper3 Colour 2
    Paper Colour4 ------ Paper Quality4 ------ Paper4 Colour 1 ------ Paper4 Colour 2
    Paper Colour5 ------ Paper Quality5 ------ Paper5 Colour 1 ------ Paper5 Colour 2
    Paper Colour6 ------ Paper Quality6 ------ Paper6 Colour 1 ------ Paper6 Colour 2

    I am not sure if this approach would be effective. Only I know this way, it will require a lengthy and repetitive procedure.

    I have just started this and thought I must ask seniors who may have come across such situations where they would have to record this kind of things and may have find out the simple logic to perform this.

    Also, I would like suggestions about how to store this information in database, because if i create a database with 6 fields for paper colour, 6 fields for paper quality and 12 fields for printing colours, it would be waste, if there are only two papers in some orders.

    Earlier in Screen Printing part, I have used a trick to store multiple colour schemes in single field by denoting each colour with a code word and store it in a single fields making it a string, like if user selected 4 colours i.e. red, black, orange and silver, i stored it like 41234 (4 to tell there are 4 colours, 1 for red, 2 for black, 3 for orange and 4 for silver) and this trick is working fine.

    I just need a logic how to perform this. Is there any better way to perform this kind of multiple selection?

    Regards

  2. #2
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: VB6 - Help With Multiple Selections Combo Boxes Or Text Boxes ?

    First for your trick: Have you only 9 possible colors? What if you had 10?
    But as you are clever you could extend the storing like 401020304.
    Then you could further think of extending the storing in strings like:
    1123,1124,1233
    each 4 digitis being paper color1, paper quality, page1 color, page 2 color.
    You could use a text field of length 30 in the database to store.
    To determine how many pages there are in the string you use the Split function.
    Code:
      Dim a$(), nPages%
      a = Split(PageInfo, ",")
      nPages = UBound(a)
    This returns you the number of pages and makes you the partial codes available in the string array.
    a(0) being the first, a(1) the second page and so on.

    On screen it seems you need as many combo boxes, BUT you would arrange them in arrays as well.
    You make only the first boxes cboPaperCol, cboPaperQual, cboPage1Col, cboPage2Col.
    These you give each an Index of 0 what makes them to the first elements of 4 control arrays.

    If you want to have all six rows of combos on screen from the beginning, (what is the easiest approach) you just copy the four and paste them in repeatedly five times and put them in place. There you are.

    Now your routines can work in loops to address the combos for making the codes.
    Code:
      Dim i%,  codes$(), c$, PageInfo$
      For i = 0 to nPages - 1
          c = cboPaperCol(i).ListIndex + 1 & cboPaperQual.ListIndex + 1 & cboPage1Col.ListIndex + 1 & cboPage2Col.ListIndex + 1
      Next
    ' now combine the codes
      PageInfo = Join(codes, ",")
    But concerning databases, in today's environments I don't think it cares if some space is wasted, except you expect billions records in your database.
    In the above concept you waste some space, too. You have to make the PageInfo field 30 characters (6x4 characters, plus max 5 commas). So you never fill all characters in every record.
    If you had 6 individual fields, you could make them exactly 4 characters long, so the waist is actually small.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured