Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Visual Basic- When I type the country name is the text box, it only shows the country with the first letter. If I were to

Visual Basic- When I type the country name is the text box, it only shows the country with the first letter. If I were to type a second letter, the listbox becomes empty. For example, When I type 'a', Angola is present. When I type 'an', there are no countries in the listbox. Any idea as to how I can fix that?

Public Class frmUnitedNations Dim nations() As String = IO.File.ReadAllLines("Nations.txt") Private Sub frmUnitedNations(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load lstOutput.DataSource = nations lstOutput.SelectedItem = Nothing End Sub

Private Sub txtCountry_TextChanged(sender As Object, e As EventArgs) Handles txtCountry.TextChanged Dim query = From nation In nations Where nation.StartsWith(txtCountry.Text.ToUpper) Select nation lstOutput.DataSource = query.ToList() lstOutput.SelectedItem = Nothing End Sub

Private Sub lstOutput_SelectedIndexChanged(sender As Object, e As EventArgs) Handles lstOutput.Click txtCountry.Text = lstOutput.SelectedItem lstOutput.DataSource = nations lstOutput.SelectedItem = Nothing End Sub End Class

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Donald A. Carpenter Fred R. McFadden

1st Edition

8178088045, 978-8178088044

More Books

Students also viewed these Databases questions

Question

=+you think is being taxed when more money is printed? Why?

Answered: 1 week ago