Results 1 to 6 of 6

Thread: adding items in comboBox

  1. #1

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075

    adding items in comboBox

    I'm adding credit card numbers in a comboBox. I need to mask the first 12 digits with X's:

    XXXX-XXXX-XXXX-1212

    not sure how...here's my do while loop to fill in the dropdown.

    Do While objDR.Read = True
    cardNo =(objDR("credit_card_no"))
    Me.cmbCard.Items.Add(cardNo.ToString("XXXX-XXXX-XXXX-####")
    Loop
    It's tough being an unhandled exception...

    ___________
    VB.NET 2008
    VB.NET 2010
    ORACLE 11g
    CRYSTAL 11

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    So whats the question?

  3. #3

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075
    it's not working

    I've also tried this, but it's giving me an error under the RIGHT function...



    VB Code:
    1. objCon.Open()
    2.                 objDR = objCom.ExecuteReader
    3.                 Do While objDR.Read = True
    4.                     cardNo = (objDR("credit_card_no"))
    5.                     Me.cmbCard.Items.Add("XXXX-XXXX-XXXX-" & (Right(cardNo, 4)))
    6.                 Loop
    It's tough being an unhandled exception...

    ___________
    VB.NET 2008
    VB.NET 2010
    ORACLE 11g
    CRYSTAL 11

  4. #4
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Reading, UK
    Posts
    870
    is objDR("credit_card_no") a number or string?
    www.vb-tech.com
    .Net Freelance Development
    http://weblog.vb-tech.com/nick
    My blog

  5. #5

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075
    datatype = char(16)
    It's tough being an unhandled exception...

    ___________
    VB.NET 2008
    VB.NET 2010
    ORACLE 11g
    CRYSTAL 11

  6. #6
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Ahh ToString or Format doesn't really format strings into other strings just non-strings into strings.

    The second method should work, here:
    VB Code:
    1. objCon.Open()
    2.                 objDR = objCom.ExecuteReader
    3.                 Do While objDR.Read
    4.                     cardNo = (objDR("credit_card_no"))
    5.                     Me.cmbCard.Items.Add("XXXX-XXXX-XXXX-" & cardno.Substring(cardno.Length - 4, 4))
    6.                 Loop

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