Download presentation
Presentation is loading. Please wait.
1
More on lists, exceptions, loops and validation
2
You can use the exception to indicate the error that occurred Private Sub btnCheck_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCheck.Click Dim value As Integer Try value = Integer.Parse(txtinput.Text) Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub
3
Form expects integer input
4
Messagebox text comes from the exception.message
5
Listbox multicolumn property
6
Setting multicolumn to true
7
Suppose many values are added to the listbox Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim i As Integer For i = 1 To 1000 ListBox1.Items.Add(i) Next End Sub
8
Note horizontal scrollbar
9
Checked listbox: checkonclick property defaults to false
10
A form allowing city selection
11
Code to get selected cities note you need to clear listbox each time a city is checked or they’ll all be added again Private Sub clbCities_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles clbCities.SelectedIndexChanged Dim i, checkint As Integer checkint = -1 lstcities.Items.Clear() For i = 0 To clbCities.Items.Count - 1 If clbCities.GetItemChecked(i) = True Then lstcities.Items.Add(clbCities.Items(i)) End If Next End Sub
12
As selections are made…
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.