|
-
Sep 14th, 2009, 03:57 PM
#1
Thread Starter
PowerPoster
[RESOLVED] clear an array between calls
I have sub that loops the columns in a mshflexgrid and loads unique items
into 7 comboboxes. I need to clear the array between calls as the array seems to be holding values between calls. How can i do this ?
Code:
Private Type Report
RefName As String * 25
RefCnt As Long 'the count for each entry
End Type
'fill the combos with unique values
CountUniqueValues Region, cboRegion, "< All Regions >"
CountUniqueValues Referrer, cboReferer, "< All Referrers >"
CountUniqueValues Material_Style, cboMaterialStyle, "< All Material Styles >"
CountUniqueValues Material_Type, cboMaterialType, "< All Material Types >"
CountUniqueValues Material_Color, cboMaterialColor, "< All Material Colors >"
CountUniqueValues Job_Type, cboJobType, "< All Job Types >"
CountUniqueValues Entered_By, cboEnteredBy, "< All Entered By >"
CountUniqueValues Estimator, CboEstimater, "< All Estimators/Salesman >"
Sub CountUniqueValues(c As Integer, cbo As ComboBox, cboText As String)
Dim r As Long
Dim CurRef, LastRef As String
ReDim Refs(0) As Report
Dim i As Long
Dim RName As String
Dim RCount As Long
GridMisc.Col = c
GridMisc.Sort = 5 'text ascending sort
For r = 1 To GridMisc.Rows - 1
If GridMisc.TextMatrix(r, c) <> "" Then
CurRef = GridMisc.TextMatrix(r, c)
End If
If LastRef = CurRef Then
Refs(UBound(Refs)).RefCnt = Refs(UBound(Refs)).RefCnt + 1
Else
ReDim Preserve Refs(UBound(Refs) + 1)
Refs(UBound(Refs)).RefName = CurRef
Refs(UBound(Refs)).RefCnt = 1
LastRef = CurRef
End If
Next r
For i = 1 To UBound(Refs)
RName = Trim(Refs(i).RefName)
RCount = Refs(i).RefCnt
GridRecap.AddItem vbTab & RName & vbTab & CStr(RCount)
'Debug.Print RName & vbTab & CStr(RCount)
Next i
End Sub
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
Sep 14th, 2009, 04:14 PM
#2
Re: clear an array between calls
If you mean Refs(), it is already reset at the very start of the routine.
Give us details of what the issue actually is, rather than your assumption of the cause.
By the way, I don't see why you have the cbo and cboText parameters - you aren't using them.
-
Sep 14th, 2009, 04:16 PM
#3
Re: clear an array between calls
-
Sep 14th, 2009, 04:18 PM
#4
Re: clear an array between calls
If you want to clear a dynamic array then you can use ERASE.
-
Sep 14th, 2009, 06:29 PM
#5
Thread Starter
PowerPoster
Re: clear an array between calls
I thought that the array was the problem, because when i changed the order of loading the cbo's the first cbo was always correct and the cbo's that followed
have items from the first cbo and items from the other cbo's. Basically i am loading a mshflexgrid with 40 columns from a file and using it to create reports, like a database. I scan the columns-rows and use the results in 2 other flexgrids, recap and detail. I know what everyone is thinking "Why not just use a database" I have my reasons, Listing the reasons would create a bunch of email buddies. Should know better than to think just erasing an array would fix a simple problem. Better get to debugging. Thanks guys
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
Sep 14th, 2009, 06:31 PM
#6
Thread Starter
PowerPoster
Re: clear an array between calls
 Originally Posted by si_the_geek
If you mean Refs(), it is already reset at the very start of the routine.
Give us details of what the issue actually is, rather than your assumption of the cause.
By the way, I don't see why you have the cbo and cboText parameters - you aren't using them.
I just left out that part it is before the end sub
cbo.AddItem cboText
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
Sep 14th, 2009, 06:49 PM
#7
Re: clear an array between calls
Here's a nit. In the following CurRef is a Variant and not a String.
Dim CurRef, LastRef As String
-
Sep 14th, 2009, 08:00 PM
#8
Thread Starter
PowerPoster
Re: clear an array between calls
 Originally Posted by MartinLiss
Here's a nit. In the following CurRef is a Variant and not a String.
Dim CurRef, LastRef As String
Thanks fixed that
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
Sep 14th, 2009, 08:07 PM
#9
Thread Starter
PowerPoster
Re: clear an array between calls
thanks everybody, fixed it like it should have been to begin with eg:
Adding directly to the cbo's from the array rather to a grid then the cbo's
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|