how to update that elem value ?
I have question.
I want to increase elem ,
but need check that array() that string is repeat or not.
if not found repeat. increase elem
Code:
array:
myArr(0,0) = "401"
myArr(1,0) = "2"
myArr(0,1) = "405"
myArr(1,1) = "4"
if found repear. just only changed something.
Code:
myArr(0,0) = "401"
myArr(1,0) = "7" '2+5 = increase 5 qty.
myArr(0,1) = "405"
myArr(1,1) = "4"
how to start ?
textbox: "barcode", "qty" , command1_click
please!
Code:
'form1
Private Sub Command1_Click()
Debug.Print IsArray(cartR)
Call addElem(cartR, input_barcode.Text, input_qty.Text, "new")
End Sub
Private Sub Command2_Click()
List1.Clear
Dim i As Integer
For i = LBound(cartR, 2) To UBound(cartR, 2)
List1.AddItem cartR(0, i) & ">" & cartR(1, i) & ">" & cartR(2, i) & ">"
Next i
End Sub
Code:
'module1
Option Explicit
Public cartR() As String
Public Function addElem(ByRef cartR() As String, ByVal a As String, ByVal b As String, ByVal c As String)
Dim i As Long
If Not Not cartR Then i = UBound(cartR, 2) + 1
ReDim Preserve cartR(0 To 2, i)
Dim i2 As Integer
For i2 = LBound(cartR, 2) To UBound(cartR, 2)
If CStr(cartR(0, i2)) = CStr(a) Then
cartR(0, i2) = "was" & cartR(0, i2) 'barcode
cartR(1, i2) = "was" & CStr(CDbl(cartR(1, i2)) + CDbl(b)) 'qty
cartR(2, i2) = "was" & cartR(2, i2)
Else
cartR(0, i) = a
cartR(1, i) = b
cartR(2, i) = c
End If
Next i2
End Function