Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Visual Basic- The file Nations.txt contains the names of the 193 member nations

ID: 3802382 • Letter: V

Question

Visual Basic- The file Nations.txt contains the names of the 193 member nations of the United Nations. Write a program that initially displays all the nations in a list box. Each time a letter is typed into a textbox, the program should reduce the displayed nations to those beginning with the letters in the textbox. The picture below shows the status after the letters "Ma" are typed into the textbox. At any time, the user should be able to click on the name of a nation to have it appear in the textbox.

United Nations -la x Ma Madagascar Malawi Malaysia Maldives Mali Malta Marshall Islands Mauritania Mauritius

Explanation / Answer

sub Useform_Initialize()

dim file as long

Dim Line As String

file=FreeFile()

Open "C:Nation.txt"

while not EOF(file)

Line Input #File,

Me.Listbox1.additem Line

Wend

end sub

sub Textbox1_afterupdate()

Dim var as variant

dim i as integer

var=Me.textbox1.value

end sub