473,382 Members | 1,750 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Logical Mistake

Hi: In the listbox name lstOpenAccounts there are three hundred values.
In another listbox name lstseldist there are two values but it could be
three or four. Assume from the first listbox name lstOpenAccounts I
select 150 Accounts and in the second list box name lstseldist there
are two name for accounts distribution. If its a 150 values in
lstOpenAccounts then 75 each will be distribute to each name which are
in lstseldist but the program gives 76 to one and 74 to another. Its
total is 150 but the distribution is wrong. The Program goes to Case
Else in function distributeByQuantity but it not distribute values
correctly. Dont know what logic i use so that the accounts will be
distributed correctly. NEEDS HELP

Private Sub cmdAssignAccounts_Click()
Dim multiUserDistCount As Integer

Screen.MousePointer = vbHourglass
Set AcctsToDist = Nothing
If optEvenDollarDist.Value = True Then
distributeByEvenDollar
Else
distributeByQuantity (multiUserDistCount)
End If

Screen.MousePointer = vbNormal

'Calls frmUserReassign
If lstOpenAccounts.SelCount 0 Then
frmUserReAssign.AcctCol = Nothing
frmUserReAssign.AcctCol = AcctsToDist
Set Criteria.AccountCollection = Nothing
frmUserReAssign.Show vbModal
lstOpenAccounts.Clear
cmdSelectAll.Caption = "Select All"
End If
End Sub
---------------------------------------------------------------
Public Function FindSelectedListBoxItems(LstBx As Control) As
Collection
Dim i As Long
Dim colCollection As New Collection

For i = (LstBx.ListCount - 1) To 0 Step -1
If LstBx.Selected(i) Then
colCollection.Add LstBx.List(i)
End If
Next
Set FindSelectedListBoxItems = colCollection
Set colCollection = Nothing 'New Collection
End Function

---------------------------------------------------------------
Private Sub distributeByQuantity(multiUserDistCount As Integer)
Dim distributeTo As Collection, acctsToDistribute As Collection
Dim i As Integer, c As Integer, x As Integer, j As Integer
Dim account As String, targetAIdIndex As Integer

'Calls function in modProcessingFunctions
Set distributeTo = FindSelectedListBoxItems(lstDist)
Set acctsToDistribute = FindSelectedListBoxItems(lstOpenAccounts)
'Used to maintain correct user
x = 1
j = 1

Set AcctsToDist = New Collection

Select Case multiUserDistCount
Case 0
For i = 1 To acctsToDistribute.Count
account = acctsToDistribute(i)
targetAIdIndex = 0
'get acct location in criteria.accountcollection
Do While targetAIdIndex <= lstOpenAccounts.ListCount
If lstOpenAccounts.List(targetAIdIndex) = account Then
'set j = collection index
j = targetAIdIndex + 1
'exit while loop
targetAIdIndex = lstOpenAccounts.ListCount
End If
targetAIdIndex = targetAIdIndex + 1
Loop
'save old assign_id and set new one

Criteria.AccountCollection(j).Old_Assign_Id =
Criteria.AccountCollection(j).Assign_ID
Criteria.AccountCollection(j).Assign_ID =
Trim(distributeTo(1))
AcctsToDist.Add (Criteria.AccountCollection(j))
Next
Case Else
'Used to verify each user receives the same amt
c = 0
'distribute each account
For i = 1 To acctsToDistribute.Count
'true when c = multiuserdistcount, goes to next user
If multiUserDistCount = c - 1 Then
c = 0
x = x + 1
End If
account = acctsToDistribute(i)
targetAIdIndex = 0
'get acct location in criteria.accountcollection
Do While targetAIdIndex < lstOpenAccounts.ListCount
If lstOpenAccounts.List(targetAIdIndex) = account
Then
'set j = collection index
j = targetAIdIndex + 1
'exit while loop
targetAIdIndex = lstOpenAccounts.ListCount
End If
targetAIdIndex = targetAIdIndex + 1
Loop

Criteria.AccountCollection(j).Old_Assign_Id =
Criteria.AccountCollection(j).Assign_ID
Criteria.AccountCollection(j).Assign_ID =
Trim(distributeTo(x))

AcctsToDist.Add Criteria.AccountCollection(j)
'Adds account count to user
c = c + 1
Next
End Select

Jan 13 '07 #1
1 1135
Anna,

"Anna" <co*********@gmail.comschrieb:
Hi: In the listbox name lstOpenAccounts there are three hundred values.
In another listbox name lstseldist there are two values but it could be
three or four. Assume from the first listbox name lstOpenAccounts I
select 150 Accounts and in the second list box name lstseldist there
are two name for accounts distribution.
As your question seems to be related to VB6, I suggest to post it to one of
the VB6 groups which can be found in the "microsoft.public.vb.*" hierarchy.
This group ("microsoft.public.dotnet.languages.vb") targets VB.NET, which is
no technical successor of VB6.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Jan 13 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: muser | last post by:
Can anyone run this program through their compiler or if they can see a logical error please point it out. I have my tutor working on it at the moment but I would rather a less ambigious response...
7
by: Charles Crume | last post by:
Hello all; I have used dBASE, and other computer languages/databases, for years. They all have a logical field type. However, the version of MySQL used by the ISP hosting my site does not...
34
by: sam | last post by:
Please look at the code below #include <stdio.h> int expr(char str, int i){ printf("%s \n",str); return i; }
80
by: Christopher Benson-Manica | last post by:
Of course one can get the effect with appropriate use of existing operators, but a ^^ operator would make for nice symmetry (as well as useful to me in something I'm working on). Am I the only one...
3
by: serge | last post by:
How do I determine which method I should use if I want to optimize the performance of a database. I took Northwind's database to run my example. My query is I want to retrieve the Employees'...
2
by: dbtwo | last post by:
Until today I always thought as long as you see a lot of logical reads as compared to physical reads, then you're good. But it looks like it isn't so. But doesn't logical read mean it's being read...
11
by: Dominic Vella | last post by:
I am using MS-Access2000. I can't seem to set the default values for Logical type fields. I start with Dim dbsTmp As Object ' I think it's DAO.Database Set dbsTmp =...
7
by: cube | last post by:
Hallo everyone, I have written the below code but it doesn't work right. The problem is that when I run it, and the score_main array has a value of -3 or 3 and at the same time the...
3
by: anchitgood | last post by:
I have tried a lot but unable to correct just 1 logical error in the following code. This error is in the for loop, when fine and minutes are printed as the garbage values. Please check it out: ...
7
by: raylopez99 | last post by:
I have a logical drawing space much bigger than the viewport (the screen) and I'd like to center the viewport (the screen) to be at the center of the logical drawing space. After following the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.