Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27569

Fix the display problem.

$
0
0
Private Sub Pick_Up_Summary_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
SubmitPizza1.Text = Pick_Up_Pizza_Options.CustomerSelectedPizzaPickUp.Items(0)
SubmitPizza2.Text = Pick_Up_Pizza_Options.CustomerSelectedPizzaPickUp.Items(1)
SubmitPizza3.Text = Pick_Up_Pizza_Options.CustomerSelectedPizzaPickUp.Items(2)
SubmitPizza4.Text = Pick_Up_Pizza_Options.CustomerSelectedPizzaPickUp.Items(3)
SubmitPizza5.Text = Pick_Up_Pizza_Options.CustomerSelectedPizzaPickUp.Items(4)
End Sub

This is my code to display the first five items from the listbox called CustomerSelectedPizzaPickUp. This listbox is located in a form called Pick_Up_Pizza_Options. SubmitPizza.text are labels. This code works perfectly when i have 5 items in the listbox. But if it has less than 5 items than i get a error message saying:

InvalidArgument=Value of '()' is not valid for 'index'.
Parameter name: index

Please help me. How can i fix this issue. And the maximum number of items the listbox is allowed to have is 5 items.

Viewing all articles
Browse latest Browse all 27569

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>