Duplicate Question
The question on this page has been marked as a duplicate question.
Original Question
This is a visual basics program issue. The problem is: Table 4.7 contains information on several states. Write a program that r...Asked by Stac
This is a visual basics program issue.
The problem is: Table 4.7 contains information on several states. Write a program that requests a state and category (flower, motto and nickname) as input and displays the requested information. If the state or category requested is not in the table, the program should so inform the user.
Table 4.7 State, Flower, Nickname, and Motto
State
Flower
Nickname
Motto
California
Golden Poppy
Golden State
Eureka
Indiana
Peony
Hoosier State
Crossroads of America
Mississippi
Magnolia
Magnolia State
By valor of arms
New York
Rose
Empire State
Ever upward
This is the program I created. It only displays the very last line of the program. Could you help tell me what is missing?
Public Class Ch04_3_32A
Private Sub btnDisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
'Display state and category
Dim state As String
Dim category As String
state = (InputBox("Enter a state", "A State"))
category = (InputBox("Enter a category", "A Category"))
Select Case state.ToUpper
Case "CALIFORNIA"
Select Case category.ToUpper
Case "FLOWER"
txtOutput.Text = "Gold Poppy"
Case "NICKNAME"
txtOutput.Text = "Golden State"
Case "MOTTO"
txtOutput.Text = "Eureka"
End Select
End Select
Select Case state.ToUpper
Case "INDIANA"
Select Case category.ToUpper
Case ("FLOWER")
txtOutput.Text = "Peony"
Case ("NICKNAME")
txtOutput.Text = "Hoosier State"
Case ("MOTTO")
txtOutput.Text = "Crossroads to America"
End Select
End Select
Select Case state.ToUpper
Case "MISSISSIPPI"
Select Case category.ToUpper
Case "FLOWER"
txtOutput.Text = "Magnolia"
Case "NICKNAME"
txtOutput.Text = "Magnolia State"
Case "MOTTO"
txtOutput.Text = "By valor and arms"
End Select
End Select
Select Case state.ToUpper
Case "NEW YORK"
Select Case category.ToUpper
Case "FLOWER"
txtOutput.Text = "Rose"
Case "NICKNAME"
txtOutput.Text = "Empire State"
Case "MOTTO"
txtOutput.Text = "Ever Upward"
End Select
End Select
If state <> "" Then
txtOutput.Text = "Category is not listed"
End If
End Sub
End Class
The problem is: Table 4.7 contains information on several states. Write a program that requests a state and category (flower, motto and nickname) as input and displays the requested information. If the state or category requested is not in the table, the program should so inform the user.
Table 4.7 State, Flower, Nickname, and Motto
State
Flower
Nickname
Motto
California
Golden Poppy
Golden State
Eureka
Indiana
Peony
Hoosier State
Crossroads of America
Mississippi
Magnolia
Magnolia State
By valor of arms
New York
Rose
Empire State
Ever upward
This is the program I created. It only displays the very last line of the program. Could you help tell me what is missing?
Public Class Ch04_3_32A
Private Sub btnDisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
'Display state and category
Dim state As String
Dim category As String
state = (InputBox("Enter a state", "A State"))
category = (InputBox("Enter a category", "A Category"))
Select Case state.ToUpper
Case "CALIFORNIA"
Select Case category.ToUpper
Case "FLOWER"
txtOutput.Text = "Gold Poppy"
Case "NICKNAME"
txtOutput.Text = "Golden State"
Case "MOTTO"
txtOutput.Text = "Eureka"
End Select
End Select
Select Case state.ToUpper
Case "INDIANA"
Select Case category.ToUpper
Case ("FLOWER")
txtOutput.Text = "Peony"
Case ("NICKNAME")
txtOutput.Text = "Hoosier State"
Case ("MOTTO")
txtOutput.Text = "Crossroads to America"
End Select
End Select
Select Case state.ToUpper
Case "MISSISSIPPI"
Select Case category.ToUpper
Case "FLOWER"
txtOutput.Text = "Magnolia"
Case "NICKNAME"
txtOutput.Text = "Magnolia State"
Case "MOTTO"
txtOutput.Text = "By valor and arms"
End Select
End Select
Select Case state.ToUpper
Case "NEW YORK"
Select Case category.ToUpper
Case "FLOWER"
txtOutput.Text = "Rose"
Case "NICKNAME"
txtOutput.Text = "Empire State"
Case "MOTTO"
txtOutput.Text = "Ever Upward"
End Select
End Select
If state <> "" Then
txtOutput.Text = "Category is not listed"
End If
End Sub
End Class
Answers
Answered by
MathMate
It looks to me that the program is quite complete, except that you have used a single-line textbox for the output. Consequently, when you write other lines, the previous lines are erased.
If the problem is confirmed, then you work on configuring your original txtBox to a multi-line textbox, and everything should work out.
Otherwise, please post again.
If the problem is confirmed, then you work on configuring your original txtBox to a multi-line textbox, and everything should work out.
Otherwise, please post again.
Answered by
Stac
When you say single line textbox Output, what are you referring to? I'm I little confused with your wording.
Answered by
MathMate
Textboxes by default allow the output of only one line. If you put multiple lines in the output, you will only see the last line.
There should be a property on the textbox that allows you to show more than one line (I believe it is "multiline". When this is checked, you will have many lines for the output, if the height of the textbox is adjusted properly.
Post if you have problems.
There should be a property on the textbox that allows you to show more than one line (I believe it is "multiline". When this is checked, you will have many lines for the output, if the height of the textbox is adjusted properly.
Post if you have problems.
There are no AI answers yet. The ability to request AI answers is coming soon!
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.