Point Taken, final result will be a function. Right now it is reading
values from a listbox.
OK, what I am really trying to do is build 10 dynamic Arrays. Bumping
the referenced Array to the next using the same code block. Code is
used to build a simplified SQL statement of passed values eliminating
redundant values. Really didn't want to go multidimensional here
because of limitation that only the last element can be resized with
redim. Secondly in the below example, individual array elements whill
have varying UBounds due to different numbers of elements.
Sample Value to be Parsed: 1HGCM71626A007999
Sub VinOptimize()
'USE-OPTIMIZE SQL TO LEAST COMMON DENOMINATOR
'DEC VARS
Dim MArray1() As String
Dim MArray2() As String
Dim MArray3() As String
Dim MArray4() As String
Dim MArray5() As String
Dim MArray6() As String
Dim MArray7() As String
Dim MArray8() As String
Dim MArray9() As String
Dim MArray10() As String
Dim Bump1 As Integer
Dim Bump2 As Integer
Dim Bump3 As Integer
Dim Bump4 As Integer
Dim Bump5 As Integer
Dim Bump6 As Integer
Dim Bump7 As Integer
Dim Bump8 As Integer
Dim Bump9 As Integer
Dim Bump10 As Integer
Dim Jump1 As Label
Dim Bypass1 As Label
Dim indexval As Integer 'VARRAY INDEXER
'SET VALS
VArray1 = Array(1, 3, 4, 6, 7, 8, 9, 10, 11, 12) 'ARRAY VIN POSITION
VArray2 = Array(2, 1, 2, 1, 1, 1, 1, 1, 1, 6) 'ARRAY VIN NUM CHARS
Bump1 = 0
Bump2 = 0
Bump3 = 0
Bump4 = 0
Bump5 = 0
Bump6 = 0
Bump7 = 0
Bump8 = 0
Bump9 = 0
Bump10 = 0
'MESS USER
Call UPMess("SQL Optimization in Process")
'ARRAY1
For x = 0 To frm_viperpro.lstVIN.ListCount - 1
ckval = frm_viperpro.lstVIN.List(x) 'LOAD FIRST VIN
indexval = 0
'*********************************************************************************************************
'************************************ PROCESS 1
**********************************************************
'*********************************************************************************************************
LOOKUPVAL = Mid(ckval, VArray1(indexval), VArray2(indexval))
'LOAD INDIVIDUAL VALUES
'---------------------------------------------------------
If Bump1 = 0 Then
GoTo Jump1
Else
'--------------------------------------------------
'-------TEST FOR MATCH-----------------
flagbit = 0
For xx = 0 To Bump1 - 1
val1 = MArray1(xx)
If val1 = LOOKUPVAL Then
flagbit = 1
Exit For
End If
Next xx
'-------EVALUATE FLAGBIT------
If flagbit = 0 Then
ReDim Preserve MArray1(Bump1)
MArray1(Bump1) = LOOKUPVAL
Bump1 = Bump1 + 1
Else
'DO NOTHING
End If
GoTo Bypass1
'-----------------------------
'-----------------------------
Jump1:
ReDim Preserve MArray1(Bump1)
MArray1(Bump1) = LOOKUPVAL
Bump1 = Bump1 + 1
'-----------------------------
'--------------------------------------------------
End If
'---------------------------------------------------------
Bypass1:
'*********************************************************************************************************
'************************************ END PROCESS 1
******************************************************
'*********************************************************************************************************
indexval = indexval + 1
'*********************************************************************************************************
'************************************ PROCESS 2
**********************************************************
'*********************************************************************************************************
LOOKUPVAL = Mid(ckval, VArray1(indexval),
VArray2(indexval)) 'LOAD INDIVIDUAL VALUES
'---------------------------------------------------------
If Bump2 = 0 Then
GoTo Jump2
Else
'--------------------------------------------------
'-------TEST FOR MATCH-----------------
flagbit = 0
For xx = 0 To Bump2 - 1
val1 = MArray2(xx)
If val1 = LOOKUPVAL Then
flagbit = 1
Exit For
End If
Next xx
'-------EVALUATE FLAGBIT------
If flagbit = 0 Then
ReDim Preserve MArray2(Bump2)
MArray2(Bump2) = LOOKUPVAL
Bump2 = Bump2 + 1
Else
'DO NOTHING
End If
GoTo Bypass2
'-----------------------------
'-----------------------------
Jump2:
ReDim Preserve MArray2(Bump2)
MArray2(Bump2) = LOOKUPVAL
Bump2 = Bump2 + 1
'-----------------------------
'--------------------------------------------------
End If
'---------------------------------------------------------
Bypass2:
'*********************************************************************************************************
'************************************ END PROCESS 2
******************************************************
'*********************************************************************************************************
indexval = indexval + 1
'*********************************************************************************************************
'************************************ PROCESS 3
**********************************************************
'*********************************************************************************************************
LOOKUPVAL = Mid(ckval, VArray1(indexval),
VArray2(indexval)) 'LOAD INDIVIDUAL VALUES
'---------------------------------------------------------
If Bump3 = 0 Then
GoTo Jump3
Else
'--------------------------------------------------
'-------TEST FOR MATCH-----------------
flagbit = 0
For xx = 0 To Bump3 - 1
val1 = MArray3(xx)
If val1 = LOOKUPVAL Then
flagbit = 1
Exit For
End If
Next xx
'-------EVALUATE FLAGBIT------
If flagbit = 0 Then
ReDim Preserve MArray3(Bump3)
MArray3(Bump3) = LOOKUPVAL
Bump3 = Bump3 + 1
Else
'DO NOTHING
End If
GoTo Bypass3
'-----------------------------
'-----------------------------
Jump3:
ReDim Preserve MArray3(Bump3)
MArray3(Bump3) = LOOKUPVAL
Bump3 = Bump3 + 1
'-----------------------------
'--------------------------------------------------
End If
'---------------------------------------------------------
Bypass3:
'*********************************************************************************************************
'************************************ END PROCESS 3
******************************************************
'*********************************************************************************************************
indexval = indexval + 1
'*********************************************************************************************************
'************************************ PROCESS 4
**********************************************************
'*********************************************************************************************************
LOOKUPVAL = Mid(ckval, VArray1(indexval),
VArray2(indexval)) 'LOAD INDIVIDUAL VALUES
'---------------------------------------------------------
If Bump4 = 0 Then
GoTo Jump4
Else
'--------------------------------------------------
'-------TEST FOR MATCH-----------------
flagbit = 0
For xx = 0 To Bump4 - 1
val1 = MArray4(xx)
If val1 = LOOKUPVAL Then
flagbit = 1
Exit For
End If
Next xx
'-------EVALUATE FLAGBIT------
If flagbit = 0 Then
ReDim Preserve MArray4(Bump4)
MArray4(Bump4) = LOOKUPVAL
Bump4 = Bump4 + 1
Else
'DO NOTHING
End If
GoTo Bypass4
'-----------------------------
'-----------------------------
Jump4:
ReDim Preserve MArray4(Bump4)
MArray4(Bump4) = LOOKUPVAL
Bump4 = Bump4 + 1
'-----------------------------
'--------------------------------------------------
End If
'---------------------------------------------------------
Bypass4:
'*********************************************************************************************************
'************************************ END PROCESS 4
******************************************************
'*********************************************************************************************************
indexval = indexval + 1
'*********************************************************************************************************
'************************************ PROCESS 5
**********************************************************
'*********************************************************************************************************
LOOKUPVAL = Mid(ckval, VArray1(indexval),
VArray2(indexval)) 'LOAD INDIVIDUAL VALUES
'---------------------------------------------------------
If Bump5 = 0 Then
GoTo Jump5
Else
'--------------------------------------------------
'-------TEST FOR MATCH-----------------
flagbit = 0
For xx = 0 To Bump5 - 1
val1 = MArray5(xx)
If val1 = LOOKUPVAL Then
flagbit = 1
Exit For
End If
Next xx
'-------EVALUATE FLAGBIT------
If flagbit = 0 Then
ReDim Preserve MArray5(Bump5)
MArray5(Bump5) = LOOKUPVAL
Bump5 = Bump5 + 1
Else
'DO NOTHING
End If
GoTo Bypass5
'-----------------------------
'-----------------------------
Jump5:
ReDim Preserve MArray5(Bump5)
MArray5(Bump5) = LOOKUPVAL
Bump5 = Bump5 + 1
'-----------------------------
'--------------------------------------------------
End If
'---------------------------------------------------------
Bypass5:
'*********************************************************************************************************
'************************************ END PROCESS 5
******************************************************
'*********************************************************************************************************
indexval = indexval + 1
'*********************************************************************************************************
'************************************ PROCESS 6
**********************************************************
'*********************************************************************************************************
LOOKUPVAL = Mid(ckval, VArray1(indexval),
VArray2(indexval)) 'LOAD INDIVIDUAL VALUES
'---------------------------------------------------------
If Bump6 = 0 Then
GoTo Jump6
Else
'--------------------------------------------------
'-------TEST FOR MATCH-----------------
flagbit = 0
For xx = 0 To Bump6 - 1
val1 = MArray6(xx)
If val1 = LOOKUPVAL Then
flagbit = 1
Exit For
End If
Next xx
'-------EVALUATE FLAGBIT------
If flagbit = 0 Then
ReDim Preserve MArray6(Bump6)
MArray6(Bump6) = LOOKUPVAL
Bump6 = Bump6 + 1
Else
'DO NOTHING
End If
GoTo Bypass6
'-----------------------------
'-----------------------------
Jump6:
ReDim Preserve MArray6(Bump6)
MArray6(Bump6) = LOOKUPVAL
Bump6 = Bump6 + 1
'-----------------------------
'--------------------------------------------------
End If
'---------------------------------------------------------
Bypass6:
'*********************************************************************************************************
'************************************ END PROCESS 6
******************************************************
'*********************************************************************************************************
indexval = indexval + 1
'*********************************************************************************************************
'************************************ PROCESS 7
**********************************************************
'*********************************************************************************************************
LOOKUPVAL = Mid(ckval, VArray1(indexval), VArray2(indexval))
'LOAD INDIVIDUAL VALUES
'---------------------------------------------------------
If Bump7 = 0 Then
GoTo Jump7
Else
'--------------------------------------------------
'-------TEST FOR MATCH-----------------
flagbit = 0
For xx = 0 To Bump7 - 1
val1 = MArray7(xx)
If val1 = LOOKUPVAL Then
flagbit = 1
Exit For
End If
Next xx
'-------EVALUATE FLAGBIT------
If flagbit = 0 Then
ReDim Preserve MArray7(Bump7)
MArray7(Bump7) = LOOKUPVAL
Bump7 = Bump7 + 1
Else
'DO NOTHING
End If
GoTo Bypass7
'-----------------------------
'-----------------------------
Jump7:
ReDim Preserve MArray7(Bump7)
MArray7(Bump7) = LOOKUPVAL
Bump7 = Bump7 + 1
'-----------------------------
'--------------------------------------------------
End If
'---------------------------------------------------------
Bypass7:
'*********************************************************************************************************
'************************************ END PROCESS 7
******************************************************
'*********************************************************************************************************
indexval = indexval + 1
'*********************************************************************************************************
'************************************ PROCESS 8
**********************************************************
'*********************************************************************************************************
LOOKUPVAL = Mid(ckval, VArray1(indexval),
VArray2(indexval)) 'LOAD INDIVIDUAL VALUES
'---------------------------------------------------------
If Bump8 = 0 Then
GoTo Jump8
Else
'--------------------------------------------------
'-------TEST FOR MATCH-----------------
flagbit = 0
For xx = 0 To Bump8 - 1
val1 = MArray8(xx)
If val1 = LOOKUPVAL Then
flagbit = 1
Exit For
End If
Next xx
'-------EVALUATE FLAGBIT------
If flagbit = 0 Then
ReDim Preserve MArray8(Bump8)
MArray8(Bump8) = LOOKUPVAL
Bump8 = Bump8 + 1
Else
'DO NOTHING
End If
GoTo Bypass8
'-----------------------------
'-----------------------------
Jump8:
ReDim Preserve MArray8(Bump8)
MArray8(Bump8) = LOOKUPVAL
Bump8 = Bump8 + 1
'-----------------------------
'--------------------------------------------------
End If
'---------------------------------------------------------
Bypass8:
'*********************************************************************************************************
'************************************ END PROCESS 8
******************************************************
'*********************************************************************************************************
indexval = indexval + 1
'*********************************************************************************************************
'************************************ PROCESS 9
**********************************************************
'*********************************************************************************************************
LOOKUPVAL = Mid(ckval, VArray1(indexval),
VArray2(indexval)) 'LOAD INDIVIDUAL VALUES
'---------------------------------------------------------
If Bump9 = 0 Then
GoTo Jump9
Else
'--------------------------------------------------
'-------TEST FOR MATCH-----------------
flagbit = 0
For xx = 0 To Bump9 - 1
val1 = MArray9(xx)
If val1 = LOOKUPVAL Then
flagbit = 1
Exit For
End If
Next xx
'-------EVALUATE FLAGBIT------
If flagbit = 0 Then
ReDim Preserve MArray9(Bump9)
MArray9(Bump9) = LOOKUPVAL
Bump9 = Bump9 + 1
Else
'DO NOTHING
End If
GoTo Bypass9
'-----------------------------
'-----------------------------
Jump9:
ReDim Preserve MArray9(Bump9)
MArray9(Bump9) = LOOKUPVAL
Bump9 = Bump9 + 1
'-----------------------------
'--------------------------------------------------
End If
'---------------------------------------------------------
Bypass9:
'*********************************************************************************************************
'************************************ END PROCESS 9
******************************************************
'*********************************************************************************************************
indexval = indexval + 1
'*********************************************************************************************************
'************************************ PROCESS 10
**********************************************************
'*********************************************************************************************************
LOOKUPVAL = Mid(ckval, VArray1(indexval),
VArray2(indexval)) 'LOAD INDIVIDUAL VALUES
'---------------------------------------------------------
If Bump10 = 0 Then
GoTo Jump10
Else
'--------------------------------------------------
'-------TEST FOR MATCH-----------------
flagbit = 0
For xx = 0 To Bump10 - 1
val1 = MArray10(xx)
If val1 = LOOKUPVAL Then
flagbit = 1
Exit For
End If
Next xx
'-------EVALUATE FLAGBIT------
If flagbit = 0 Then
ReDim Preserve MArray10(Bump10)
MArray10(Bump10) = LOOKUPVAL
Bump10 = Bump10 + 1
Else
'DO NOTHING
End If
GoTo Bypass10
'-----------------------------
'-----------------------------
Jump10:
ReDim Preserve MArray10(Bump10)
MArray10(Bump10) = LOOKUPVAL
Bump10 = Bump10 + 1
'-----------------------------
'--------------------------------------------------
End If
'---------------------------------------------------------
Bypass10:
'*********************************************************************************************************
'************************************ END PROCESS 10
******************************************************
'*********************************************************************************************************
Next x
'FINAL RESULT-ARRAYS CONTAIN LOWEST DENOMINATER OF PASSED VALUE
End Sub |