Results 1 to 1 of 1

Thread: [RESOLVED] ListBox.item(index)

  1. #1

    Thread Starter
    Lively Member mikelynch's Avatar
    Join Date
    May 2006
    Location
    Goombungee Qld
    Posts
    83

    Resolved [RESOLVED] ListBox.item(index)

    Can you tell me the neatest way to get the correct listbox item, and then assign it a new value from the database. The code below can't work because the
    intAccount as an index would only work if the Account numbers in the listbox
    were sequential. but they go like 1,2,4,5,8,10 etc .....


    VB Code:
    1. decAmount = ds.Tables(0).Rows(intR)("fldAmount")
    2.    intAccount = ds.Tables(0).Rows(intR)("fkAccountID")
    3.    If decAmount > 0 And decAmount  Then
    4.    ListBox1.Items(intAccount - 1).Deposit(Today, decAmount, "Auto Deposit")

    Well I did it but kinda messy
    VB Code:
    1. intCount = ListBox1.Items.Count()
    2.         For intR = 0 To intX - 1
    3.             decAmount = ds.Tables(0).Rows(intR)("fldAmount")
    4.             intAccount = ds.Tables(0).Rows(intR)("fkAccountID")
    5.             If decAmount > 0 And decAmount Then
    6.                 For inty = 0 To intCount - 1
    7.                     intAcc = ListBox1.Items(inty).AccountNumber
    8.                     If intAcc = intAccount Then
    9.                         ListBox1.Items(inty).Deposit(Today, decAmount, "Automatic Deposit")
    10.                     End If
    11.                 Next
    12.  
    13.             End If
    14.         Next
    Last edited by mikelynch; Jul 16th, 2006 at 08:57 AM.

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