I am trying to make an array so I can store monthly coffee usages. I have used the code below which puts the monthly usages into a listbox and enables me to store new usages by entering them into a textbox and clicking a button. However, I want the values to store into the application and for them to be present when I re-open the application. I'd like to know if that's possible. Thanks

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMonthlyUsage.Click

Dim coffeeusage(12) As Double

coffeeusage(0) = "400.5"
coffeeusage(1) = "450"
coffeeusage(2) = "475.5"
coffeeusage(3) = "336.5"
coffeeusage(4) = "457"
coffeeusage(5) = "325"
coffeeusage(6) = "220.5"
coffeeusage(7) = "276"
coffeeusage(8) = "300"
coffeeusage(9) = "320.5"
coffeeusage(10) = "400.5"
coffeeusage(11) = "415"

lstUsageAmount.Items.Clear()

Dim i As Double
For i = 0 To 11
lstUsageAmount.Items.Add(coffeeusage(i))
Next i

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNewAmount.Click
Dim newAmount As Double
newAmount = Val(txtNewAmount.Text)

lstUsageAmount.Items.Add(newAmount)

Edited 4 Years Ago by LFCDay123: n/a

However, I want the values to store into the application and for them to be present when I re-open the application.

What you mean about store into application?
You can save it to text file and load it when application running.
by the way, what is the function of your array? you store values into array then add it into listbox. why you don't add it to listbox directly?

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