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

I need to create an application that allows the user to enter an integer between

ID: 3544429 • Letter: I

Question

I need to create an application that allows the user to enter an integer between 1 and 10 into a text box on a form in VB. Use a Select Case statement to indentify 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. Input validation: Do not accept a number less than 1 or greater than 10. If the user enters a number outside this range, display an error message.

Explanation / Answer

Imports System.Windows.Forms

Imports System.Drawing


Public Class WinVBApp

Inherits Form


Public Sub New


Me.Text = "Integer to Roman"

Me.Size = New Size(250, 200)

Me.InitUI

Me.CenterToScreen


End Sub


Private Sub InitUI


Dim txtInteger As New TextBox

txtInteger.Parent = Me

txtInteger.Location = New Point(60, 100)

Dim lableRomanVal As Label

lableRomanVal.Parent = Me

lableRomanVal.Location = New Point(20, 80)

Dim submit As New Button

submit.Location = New Point(80, 1000)

submit.Text = "Submit"

submit.Parent = Me


AddHandler submit.Click, AddressOf Me.OnClick


Me.CenterToScreen


End Sub


Private Sub OnClick(ByVal sender As Object, ByVal e As EventArgs)

Dim integerValue As Integer = CInt(Me.txtInteger.Text)

Select Case integerValue

Case 1

Me.lableRomanVal.Text = "I"

Case 2

Me.lableRomanVal.Text = "II"

Case 3

Me.lableRomanVal.Text = "III"

Case 4

Me.lableRomanVal.Text = "IV"

Case 5

Me.lableRomanVal.Text = "V"

Case 6

Me.lableRomanVal.Text = "VI"

Case 7

Me.lableRomanVal.Text = "VII"

Case 8

Me.lableRomanVal.Text = "VIII"

Case 9

Me.lableRomanVal.Text = "IX"

Case 10

Me.lableRomanVal.Text = "X"

Case Else

Me.lableRomanVal.Text = "Enter an Integer between 1 and 10 only"

End Select


End Sub


Public Shared Sub Main

Application.Run(New WinVBApp)

End Sub


End Class

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