I have program:

Dim ItemCode(6) As String
Dim Description(6) As String
Dim price(6) As Currency
Dim Quantity As Integer
Dim SaleCost As Currency
Dim item As String
Dim position As Integer


Option Explicit

Private Sub Command1_Click()

item = Text3.Text
Quantity = Val(Text2.Text)

If Option2.Value = True Then
    Call CodeSearch(item)
Else
    Call DescriptionSearch(item)
End If

SaleCost = price(position) * Quantity
Text4.Text = ItemCode(position) & " - " & Description(position) & " - " & Quantity & " - " & price(position) & " - " & SaleCost
Text5.Text = SaleCost
Text6.Text = Discount(SaleCost)


End Sub

Private Function Discount(curr As Currency) As Currency
    Dim temp As Currency
    
    If curr < 15 Then
        temp = 0
    ElseIf (curr > 14.99) And (curr < 30) Then
        temp = 0.05
    ElseIf (curr > 29.99) Then
        temp = 0.1
    End If
    
    Discount = curr - (curr * temp)
        
End Function
Private Sub CodeSearch(ByVal code As String)
Dim i As Integer
For i = 1 To 6
    If ItemCode(i) = code Then
        position = i
        Exit For
    End If
Next i
End Sub

Private Sub DescriptionSearch(ByVal Desc As String)
Dim i As Integer
For i = 1 To 6
    If Description(i) = Desc Then
        position = i
        Exit For
    End If
Next i
End Sub

Private Sub Form_Load()
ItemCode(1) = "A349"
ItemCode(2) = "B359"
ItemCode(3) = "C369"
ItemCode(4) = "D379"
ItemCode(5) = "E389"
ItemCode(6) = "F399"

Description(1) = "keyring"
Description(2) = "mug"
Description(3) = "scarf"
Description(4) = "pen"
Description(5) = "doll"
Description(6) = "pencil"

price(1) = 5.99
price(2) = 9.99
price(3) = 14.5
price(4) = 2.49
price(5) = 7.99
price(6) = 0.85

End Sub

know i have to do:
- first button have to only add items to order list and keep them there (textbox4)
- add another button to add discount (textbox6) and calculate total cost + 17,5% VAT (textbox5) . it have to calculate all items from textbox4

can someone help me with that?

i dont know how to save all add items on the list and calcluate total cost from that. i alreadyy add checkout button an its work

Dim ItemCode(6) As StringDim Description(6) As StringDim price(6) As CurrencyDim Quantity As IntegerDim SaleCost As CurrencyDim item As StringDim position As Integer Option Explicit Private Sub Command1_Click() item = Text3.TextQuantity = Val(Text2.Text) If Option2.Value = True Then Call CodeSearch(item)Else Call DescriptionSearch(item)End If SaleCost = price(position) * QuantityText4.Text = ItemCode(position) & " - " & Description(position) & " - " & Quantity & " - " & price(position) & " - " & SaleCostText5.Text = SaleCostText6.Text = Discount(SaleCost) End Sub Private Function Discount(curr As Currency) As Currency Dim temp As Currency If curr < 15 Then temp = 0 ElseIf (curr > 14.99) And (curr < 30) Then temp = 0.05 ElseIf (curr > 29.99) Then temp = 0.1 End If Discount = curr - (curr * temp) End FunctionPrivate Sub CodeSearch(ByVal code As String)Dim i As IntegerFor i = 1 To 6 If ItemCode(i) = code Then position = i Exit For End IfNext iEnd Sub Private Sub DescriptionSearch(ByVal Desc As String)Dim i As IntegerFor i = 1 To 6 If Description(i) = Desc Then position = i Exit For End IfNext iEnd Sub Private Sub Form_Load()ItemCode(1) = "A349"ItemCode(2) = "B359"ItemCode(3) = "C369"ItemCode(4) = "D379"ItemCode(5) = "E389"ItemCode(6) = "F399" Description(1) = "keyring"Description(2) = "mug"Description(3) = "scarf"Description(4) = "pen"Description(5) = "doll"Description(6) = "pencil" price(1) = 5.99price(2) = 9.99price(3) = 14.5price(4) = 2.49price(5) = 7.99price(6) = 0.85 End SubDim ItemCode(6) As String
Dim Description(6) As String
Dim price(6) As Currency
Dim Quantity As Integer
Dim SaleCost As Currency
Dim item As String
Dim position As Integer


Option Explicit

Private Sub Command1_Click()

item = Text3.Text
Quantity = Val(Text2.Text)

If Option2.Value = True Then
Call CodeSearch(item)
Else
Call DescriptionSearch(item)
End If

SaleCost = price(position) * Quantity
Text4.Text = ItemCode(position) & " - " & Description(position) & " - " & Quantity & " - " & price(position) & " - " & SaleCost
Text5.Text = SaleCost
Text6.Text = Discount(SaleCost)


End Sub

Private Function Discount(curr As Currency) As Currency
Dim temp As Currency

If curr < 15 Then
temp = 0
ElseIf (curr > 14.99) And (curr < 30) Then
temp = 0.05
ElseIf (curr > 29.99) Then
temp = 0.1
End If

Discount = curr - (curr * temp)

End Function
Private Sub CodeSearch(ByVal code As String)
Dim i As Integer
For i = 1 To 6
If ItemCode(i) = code Then
position = i
Exit For
End If
Next i
End Sub

Private Sub DescriptionSearch(ByVal Desc As String)
Dim i As Integer
For i = 1 To 6
If Description(i) = Desc Then
position = i
Exit For
End If
Next i
End Sub

Private Sub Form_Load()
ItemCode(1) = "A349"
ItemCode(2) = "B359"
ItemCode(3) = "C369"
ItemCode(4) = "D379"
ItemCode(5) = "E389"
ItemCode(6) = "F399"

Description(1) = "keyring"
Description(2) = "mug"
Description(3) = "scarf"
Description(4) = "pen"
Description(5) = "doll"
Description(6) = "pencil"

price(1) = 5.99
price(2) = 9.99
price(3) = 14.5
price(4) = 2.49
price(5) = 7.99
price(6) = 0.85

End Sub

update:

Dim ItemCode(6) As String
Dim Description(6) As String
Dim price(6) As Currency
Dim Quantity As Integer
Dim SaleCost As Currency
Dim item As String
Dim position As Integer


Option Explicit

Private Sub Command1_Click()

item = Text3.Text
Quantity = Val(Text2.Text)

If Option2.Value = True Then
Call CodeSearch(item)
Else
Call DescriptionSearch(item)
End If

SaleCost = price(position) * Quantity
Picture1.Print ItemCode(position) & " - " & Description(position) & " - " & Quantity & " - " & price(position) & " - " & SaleCost



End Sub

Private Function Discount(curr As Currency) As Currency
Dim temp As Currency
If curr < 15 Then
temp = 0
ElseIf (curr > 14.99) And (curr < 30) Then
temp = 0.05
ElseIf (curr > 29.99) Then
temp = 0.1
End If
Discount = curr - (curr * temp)



End Function
Private Sub CodeSearch(ByVal code As String)
Dim i As Integer
For i = 1 To 6
If ItemCode(i) = code Then
position = i
Exit For
End If
Next i
End Sub

Private Sub DescriptionSearch(ByVal Desc As String)
Dim i As Integer
For i = 1 To 6
If Description(i) = Desc Then
position = i
Exit For
End If
Next i
End Sub

Private Sub Command2_Click()


Text5.Text = SaleCost
Text6.Text = Discount(SaleCost)

End Sub

Private Sub Form_Load()
ItemCode(1) = "A349"
ItemCode(2) = "B359"
ItemCode(3) = "C369"
ItemCode(4) = "D379"
ItemCode(5) = "E389"
ItemCode(6) = "F399"

Description(1) = "keyring"
Description(2) = "mug"
Description(3) = "scarf"
Description(4) = "pen"
Description(5) = "doll"
Description(6) = "pencil"

price(1) = 5.99
price(2) = 9.99
price(3) = 14.5
price(4) = 2.49
price(5) = 7.99
price(6) = 0.85

End Sub

how u see program printing order in picturebox1 now i have to add all prices from list and add 17,5% VAT in textbox5

and calculate discount in textbox6

Edited 6 Years Ago by pytup: n/a

update. I already done what i wanted. know i have to add 17,5% VAT to price after discount i dont know how to calculate that.

Dim ItemCode(6) As String
Dim Description(6) As String
Dim price(6) As Currency
Dim Quantity As Integer
Dim SaleCost As Currency
Dim item As String
Dim position As Integer
Dim totalcost As Currency



Option Explicit

Private Sub Command1_Click()

item = Text3.Text
Quantity = Val(Text2.Text)

If Option2.Value = True Then
Call CodeSearch(item)
Else
Call DescriptionSearch(item)
End If

SaleCost = price(position) * Quantity
totalcost = totalcost + SaleCost

Picture1.Print ItemCode(position) & "           " & Description(position) & "             " & Quantity & "              " & price(position) & "          " & SaleCost



End Sub

Private Function Discount(curr As Currency) As Currency
Dim temp As Currency
If curr < 15 Then
temp = 0
ElseIf (curr > 14.99) And (curr < 30) Then
temp = 0.05
ElseIf (curr > 29.99) Then
temp = 0.1
End If
Discount = curr - (curr * temp)



End Function
Private Sub CodeSearch(ByVal code As String)
Dim i As Integer
For i = 1 To 6
If ItemCode(i) = code Then
position = i
Exit For
End If
Next i
End Sub

Private Sub DescriptionSearch(ByVal Desc As String)
Dim i As Integer
For i = 1 To 6
If Description(i) = Desc Then
position = i
Exit For
End If
Next i
End Sub

Private Sub Command2_Click()


Text6.Text = Discount(totalcost)

Text5.Text = totalcost

End Sub

Private Sub Form_Load()
ItemCode(1) = "A349"
ItemCode(2) = "B359"
ItemCode(3) = "C369"
ItemCode(4) = "D379"
ItemCode(5) = "E389"
ItemCode(6) = "F399"

Description(1) = "keyring"
Description(2) = "mug"
Description(3) = "scarf"
Description(4) = "pen"
Description(5) = "doll"
Description(6) = "pencil"

price(1) = 5.99
price(2) = 9.99
price(3) = 14.5
price(4) = 2.49
price(5) = 7.99
price(6) = 0.85

End Sub
This article has been dead for over six months. Start a new discussion instead.