Hi Everyone!

I have made form 5 to become a simple storage system to check for item stocks plus adding, and started to code with arrays.

heres what I have so far.

Public Class Form5

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckButton.Click
        Dim item(2) As String
        Dim itemstocks(2) As Integer
        If ListBox1.SelectedIndex = 0 Then
            itemstocks(0) = 100
            Label1.Text = itemstocks(0).ToString
        End If
    End Sub

    Private Sub AddButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddButton.Click
        Dim stockamoumnt As Integer
        Dim itemstocks(2) As Integer
        If ListBox1.SelectedIndex = 0 Then

            stockamoumnt = Integer.Parse(StockTextBox.Text)
            itemstocks(0) = 100 + stockamoumnt
            Label1.Text = itemstocks(0).tostring
        End If
    End Sub

    Private Sub ClearButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearButton.Click
        Label1.Text = ""
    End Sub
End Class

The part I highlighted red, I want to perform the adding of my stock for the item, but I don't want it to be 100, even thought the part in green I made it to become 100(just to see if it works),What I really wanted it to be able to do is link with another form, so the itemstocks(0) can be vary.
for example:
In form3 I have a listbox for my items, and each i assign it with 100,150 and 200 items to the itemstocks.I made a purchase button and a textbox to purchase the amount of a certain item, so when items are purchased, the amount decreases by the amount purchased, and in form 5 I might be able to check it, and be able to add the stock amount for the ones which run out.

Any suggestions about how to make it is appreciated.

Thank you!

Your post is very confusing to figure out.
In just a few words, explain what "exactly" is the problem you need help with.

Sorry about the description.
So, simply, the problem is I actually want the array itemstock(2) to assign specific values to it, and be able to perform adding on the value.

Public Class Form1
    '// declared array.
    Private itemstocks(2) As Integer

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        '// assign specific values.
        itemstocks(0) = 100
        itemstocks(1) = 200
        itemstocks(2) = 300
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        '// add on to the values.
        itemstocks(0) += 50
        MsgBox(itemstocks(0)) '// result: 150
        itemstocks(1) += 50
        MsgBox(itemstocks(1)) '// result: 250
        itemstocks(2) += 50
        MsgBox(itemstocks(2)) '// result: 350
    End Sub
End Class

Okay,I see where to fix the problem.
I Just didn't know how to assign values to arrays individually.
Thanks a lot Codeorder for both the Thread u applied!

This question has already been answered. Start a new discussion instead.