Billing Software Source Code In Vb6 Array Ubound

Posted onby
Active9 months ago

Of course, in this particular case, since VB 6 allows you to use variables with a lower bound that is not 0, it's probably best to code the loop like this: Dim i As Integer For i = LBound(arffArray) To UBound(arffArray) ' Do something with the array Next i. VB Code - Menghapus Seluruh Komentar Visual Basic 6.0 Di bawah ini merupakan fungsi VB6 untuk menghapus seluruh komentar yang terdapat dalam source code Visual Basic 6.0. Kami membuatnya menjadi dua fungsi, fungsi pertama untuk menghapus seluruh komentar sedangkan fungsi yang kedua untuk menghapus seluruh line kosong. This Water billing system is an automated system that aims to minimize the process in paying the water bills. It is also designed to accommodate the complex water requirements and day to day work. It’s an easy to use system and the functions can be easily learned. Create Job Estimator with embedded Database and Array in Visual Basic.Net, other functions of this project include a currency converter, real time, date and a calculator. I am Sarfaraz. Friends I am working on a billing project in VB6 and access. I have to save the information of a client like Id, Account No, name etc and most important Items(from a combo box) and then based on that combo box item select type of item from another combo box and finally length and width of that item and save them in a database.

I'm having difficulties to find a way to add 1d array to a 2d array in VB. For example:

Barcode source code in vb6

Note that the code above is just a demonstration on what I want to achieve, it doesn't work.

I have been trying things suggested on forum such as:

  1. ReDim Preserve
  2. Array.Resize
  3. Making 2d loop to copy everysingle element to a new variable and add new element then ReDim it back to arr

All I tried, but they all doesn't seem to work. At the end of the day, I'm looking for a subroutine that could append an 2d array of unknown length for example:

John.AppleJohn.Apple

1 Answer

You need to Redim Preserve the array, but you cannot do that because it adds another column when you want another row. So you will have to define a new array and copy the data:

Barcode Source Code In Vb6

You can avoid this problem by forcing yourself into having an array with two rows and variable number of columns, but then you won't be able to initialize it that easily and it will probably be more difficult to work with in general:

However you should not use arrays for this to begin with. You should use lists:

GSerg

Source Code In Vb6

GSerg
63k15 gold badges115 silver badges250 bronze badges
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.

Not the answer you're looking for? Browse other questions tagged arraysvb.netmultidimensional-arrayappend or ask your own question.

Permalink

Join GitHub today

GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.

Sign up
Find file Copy path
Cannot retrieve contributors at this time
VERSION1.0CLASS
BEGIN
MultiUse=-1'True
END
AttributeVB_Name='ArrayList'
AttributeVB_GlobalNameSpace=False
AttributeVB_Creatable=False
AttributeVB_PredeclaredId=False
AttributeVB_Exposed=False
OptionBase0'Index all arrays from 0
PrivateConstDEFAULT_CAPACITYAsLong=10' The default intial capacity of the ArrayList
PrivateConstMAX_ARRAY_SIZEAsLong=2147483639' maximum size of array to allocate
PrivateelementData()AsVariant' The actual array of Variants in the ArrayList
PrivatesizeAsLong' size of the ArrayList
PrivatemodCountAsLong' The number of times this list has been structurally modified
PrivateSubClass_Initialize()
size=0
ReDimelementData(0ToDEFAULT_CAPACITY)
EndSub
'Trims the capacity of this ArrayList instance to list's current size. An application can use this operation to minimize the storage of an ArrayList instance
PublicSubtrimToSize()
modCount=modCount+1
Ifsize<UBound(elementData)Then
ReDimPreserveelementData(0Tosize)
EndIf
EndSub
PublicSubensureCapacity(minCapacityAsLong)
modCount=modCount+1
'Overflow-conscious code
IfminCapacity-UBound(elementData)>0Then
grow(minCapacity)
EndIf
EndSub
PrivateSubgrow(minCapacityAsLong)
'Overflow-conscious code
DimoldCapacityAsLong
oldCapacity=UBound(elementData)
DimnewCapacityAsLong
newCapacity=oldCapacity+(oldCapacity/2)
IfnewCapacity-minCapacity<0Then
newCapacity=minCapacity
EndIf
IfnewCapacity-MAX_ARRAY_SIZE>0Then
newCapacity=hugeCapacity(minCapacity)
EndIf
'minCapacity is usually close to size, so this is a win
ReDimPreserveelementData(0TonewCapacity)
EndSub
PrivateFunctionhugeCapacity(minCapacityAsLong)AsLong
IfminCapacity<0Then
err.Raise6' overflow
EndIf
hugeCapacity=IIf(minCapacity>MAX_ARRAY_SIZE,_
2147483647,MAX_ARRAY_SIZE)
EndFunction
PrivateSubensureCapacityInternal(minCapacityAsLong)
ensureExplicitCapacity(minCapacity)
EndSub
PrivateSubensureExplicitCapacity(minCapacityAsLong)
modCount=modCount+1
'overflow-conscious code
IfminCapacity-UBound(elementData)>0Then
grow(minCapacity)
EndIf
EndSub
PrivatePropertyLetsetSize(valueAsLong)
size=value
EndProperty
' Returns the number of elements in this list
PublicPropertyGetgetSize()AsLong
getSize=size
EndProperty
'Returns true if this list contains no elements
PublicFunctionisEmpty()AsBoolean
isEmpty=(size=0)
EndFunction
' Returns true if this list contains the specified element
PublicFunctioncontains(oAsVariant)AsBoolean
contains=(indexOf(o)>=0)
EndFunction
'Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element
PublicFunctionindexOf(oAsVariant)AsLong
DimiAsLong
Ifo=EmptyThen
Fori=0TosizeStep1
IfelementData(i)IsNothingThen
indexOf=i
ExitFunction
EndIf
Nexti
Else
Fori=0TosizeStep1
Ifo=elementData(i)Then
indexOf=i
ExitFunction
EndIf
Nexti
EndIf
indexOf=-1
EndFunction
'Returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element
PublicFunctionlastIndexOf(oAsVariant)AsLong
DimiAsLong
If(oIsNothing)Then
Fori=size-1To0Step1
IfelementData(i)IsNothingThen
lastIndexOf=i
ExitFunction
EndIf
Nexti
Else
Fori=size-1To0Step1
IfoIselementData(i)Then
lastIndexOf=i
ExitFunction
EndIf
Nexti
EndIf
EndFunction
PublicFunctionToArray()AsVariant()
DimarrCopy()AsVariant
ReDimarrCopy(0Tosize)
DimiAsLong
Fori=0TosizeStep1
arrCopy(i)=elementData(i)
Nexti
ToArray=arrCopy
EndFunction
PublicFunctiongetIndex(indexAsLong)AsVariant
rangeCheck(index)
getIndex=elementData(index)
EndFunction
PublicFunctionsetIndex(indexAsLong,elementAsVariant)AsVariant
rangeCheck(index)
DimoldValueAsVariant
oldValue=elementData(index)
elementData(index)=element
setIndex=oldValue
EndFunction
PublicFunctionadd(eAsVariant)AsBoolean
ensureCapacityInternal(size+1)
elementData(size)=e
size=size+1
add=True
EndFunction
PublicSubaddIndex(indexAsLong,elementAsVariant)
rangeCheckForAdd(index)
ensureCapacity(size+1)
'shift current elements to the right one
arrayCopyelementData,index,elementData,index+1,size-index
elementData(index)=element
size=size+1
EndSub
PublicFunctionremoveIndex(indexAsLong)AsVariant
rangeCheck(index)
modCount=modCount+1
DimoldValueAsVariant
oldValue=elementData(index)
DimnumMovedAsLong
numMoved=size-index-1
IfnumMoved>0Then
'move the remaining elements left one
arrayCopyelementData,index+1,elementData,index,numMoved
EndIf
size=size-1
elementData(size)=Empty
removeIndex=oldValue
EndFunction
PrivateSubrangeCheck(indexAsLong)
Ifindex>=sizeThen
err.Raise9,,outOfBoundsMsg(index)
EndIf
EndSub
PrivateSubrangeCheckForAdd(indexAsLong)
Ifindex>=sizeOrindex<0Then
err.Raise9,,outOfBoundsMsg(index)
EndIf
EndSub
PrivateFunctionoutOfBoundsMsg(indexAsLong)AsString
outOfBoundsMsg='Index '&index&', Size: '&size
EndFunction
PublicFunctionremove(oAsVariant)AsBoolean
DimindexAsLong
Ifo=EmptyThen
Forindex=0TosizeStep1
IfelementData(index)IsNothingThen
fastRemove(index)
removeVariant=True
ExitFunction
EndIf
Nextindex
Else
Forindex=0TosizeStep1
IfelementData(index)=oThen
fastRemove(index)
removeVariant=True
ExitFunction
EndIf
Nextindex
EndIf
removeVariant=False
EndFunction
PrivateSubfastRemove(indexAsLong)
modCount=modCount+1
DimnumMovedAsLong
numMoved=size-index-1
IfnumMoved>0Then
arrayCopyelementData,index+1,elementData,index,numMoved
EndIf
size=size-1
elementData(size)=Null
EndSub
PublicSubclear()
modCount=modCount+1
DimiAsLong
Fori=0TosizeStep1
elementData(i)=Null
Nexti
size=0
EndSub
PublicFunctionaddAll(Arr()AsVariant)AsBoolean
DimnumNewAsLong
numNew=UBound(Arr)-LBound(Arr)
ensureCapacityInternal(size+numNew)
DimiAsLong
DimjAsLong
j=size
Fori=LBound(Arr)ToUBound(Arr)Step1
elementData(j)=Arr(i)
j=j+1
Nexti
size=size+numNew
addAll=numNew<>0
EndFunction
PublicFunctionaddAllAtIndex(indexAsLong,Arr()AsVariant)AsBoolean
rangeCheckForAdd(index)
DimnumNewAsLong
numNew=UBound(Arr)-LBound(Arr)
ensureCapacityInternal(size+numNew)
DimnumMovedAsLong
numMoved=size-index
IfnumMoved>0Then
arrayCopyelementData,index,elementData,index+numNew,numMoved
EndIf
DimiAsLong
DimjAsLong
j=LBound(Arr)
Fori=indexToindex+numNewStep1
elementData(i)=Arr(j)
j=j+1
Nexti
size=size+numNew
addAllAtIndex=numNew<>0
EndFunction
SubremoveRange(fromIndexAsLong,toIndexAsLong)
modCount=modCount+1
DimnumMovedAsLong
numMoved=size-toIndex
arrayCopyelementData,toIndex,elementData,fromIndex,numMoved
'clear to let GC do its work
DimnewSizeAsLong
newSize=size-(toIndex-fromIndex)
DimiAsLong
Fori=newSizeTosizeStep1
elementData(i)=Null
Nexti
size=newSize
EndSub
PublicFunctionremoveAll(cAsArrayList)AsBoolean
IfcIsNothingThen
err.Raise31004,,'Collection c Is Nothing'
EndIf
batchRemovec,False
EndFunction
PublicFunctionretainAll(cAsArrayList)AsBoolean
IfcIsNothingThen
err.Raise31004,,'Collection c Is Nothing'
EndIf
batchRemovec,True
EndFunction
PrivateFunctionbatchRemove(cAsArrayList,complementAsBoolean)AsBoolean
DimrAsInteger
DimwAsInteger
r=0
w=0
DimmodifiedAsBoolean
modified=False
OnErrorGoTofinally
Forr=0TosizeStep1
If(c.contains(elementData(r))=complement)Then
elementData(w)=elementData(r)
w=w+1
EndIf
Nextr
batchRemove=modified
ExitFunction
finally:
Ifr<>sizeThen
''arrayCopy elementData, r, elementData, w, size - r
w=w+size-r
EndIf
Ifw<>sizeThen
'clear to let GC do its work
DimiAsLong
Fori=wTosizeStep1
elementData(i)=Null
Nexti
modCount=modCount+size-w
size=w
modified=True
EndIf
batchRemove=modified
ExitFunction
EndFunction
PublicSubarrayCopy(ByRefsrc()AsVariant,srcPosAsLong,ByRefdst()AsVariant,dstPosAsLong,lengthAsLong)
'Check if all offsets and lengths are non negative
IfsrcPos<0OrdstPos<0Orlength<0Then
err.Raise9,,'negative value supplied'
EndIf
'Check if ranges are valid
Iflength+srcPos>UBound(src)Then
err.Raise9,,'Not enough elements to copy, src+length: '&srcPos+length&', UBound(src): '&UBound(src)
EndIf
Iflength+dstPos>UBound(dst)Then
err.Raise9,,'Not enough room in destination array. dstPos+length: '&dstPos+length&', UBound(dst): '&UBound(dst)
EndIf
DimiAsLong
i=0
'copy src elements to dst
DoWhilelength>i
dst(dstPos+i)=src(srcPos+i)
i=i+1
Loop
EndSub
PublicFunctionsubList(fromIndexAsLong,toIndexAsLong)AsArrayList
subListRangeCheckfromIndex,toIndex,Me.getSize
subList=NewArrayList
subList.addAllelementData
EndFunction
PrivateSubsubListRangeCheck(fromIndexAsLong,toIndexAsLong,curSizeAsLong)
IffromIndex<0Then
err.Raise6,,'fromIndex = '&fromIndex
EndIf
IftoIndex>curSizeThen
err.Raise6,,'toIndex = '&toIndex
EndIf
IffromIndex>toIndexThen
err.Raise328,,'fromIndex('&fromIndex&') > toIndex('&toIndex&')'
EndIf
EndSub
PublicPropertyGetNewEnum()AsIUnknown
'interface method
EndProperty
  • Copy lines
  • Copy permalink