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

When I try to run this code i get a error that txtNumber is not declared. What s

ID: 3793644 • Letter: W

Question

When I try to run this code i get a error that txtNumber is not declared. What should ut be declared as? Text? I tried String and that did not work. Here is the assignment:

Create an application that allows the user to enter an integer between 1 and 10 into a textbox on a form. Use a Select Case or If...Then…ElseIf statements to identify which Roman numeral is the correct translation of the integer. Display the Roman numeral in a Label control. If the user enters an invalid value, display an appropriate error message and do not attempt the conversion. This application must also have a “Clear” button. This button will clear out the contents of the textbox and label. It will also place the focus on the textbox. Include an “Exit” button that closes the window.

My code is listed below:

Public Class Form1
'Chloe Butler 900323171'
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim roman As String = ""
Dim txtNumber As Text
If txtNumber.Text.ToString() = Then
MessageBox.Show("Provide a integer to convert")
txtNumber.Focus()
ElseIf (Int32.Parse(txtNumber.Text.ToString()) < 1 Or Int32.Parse(txtNumber.Text.ToString()) > 10) Then
MessageBox.Show("Number out of range. Enter number between 1 and 10")
txtNumber.Text = ""
txtNumber.Focus()
ElseIf (txtNumber.Text.ToString() = "1") Then

roman = "I"

ElseIf (txtNumber.Text.ToString() = "2") Then

roman = "II"

ElseIf (txtNumber.Text.ToString() = "3") Then

roman = "III"

ElseIf (txtNumber.Text.ToString() = "4") Then

roman = "IV"

ElseIf (txtNumber.Text.ToString() = "5") Then

roman = "V"

ElseIf (txtNumber.Text.ToString() = "6") Then

roman = "VI"

ElseIf (txtNumber.Text.ToString() = "7") Then

roman = "VII"

ElseIf (txtNumber.Text.ToString() = "8") Then

roman = "VIII"

ElseIf (txtNumber.Text.ToString() = "9") Then

roman = "IX"

ElseIf (txtNumber.Text.ToString() = "10") Then

roman = "X"

End If
Dim TxtRoman As Text
TxtRoman.Text = roman.ToString()
End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim txtNumber As Text
Dim txtRoman As Text
txtNumber.Text = ""
TxtRoman.Text = ""
txtNumber.Focus()
End Sub

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Me.Close()
End Sub
End Class

Explanation / Answer

Answer:

we get error txtNumber not declared because this variable might be intialised with out declaration.The variable txtNumber must be declared as text using int or char datatype i.e char txtNumber; or int txtNumber; so that the given code works.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote