Can you help me I keep getting error on my program Can you help me what I did wr
ID: 3867943 • Letter: C
Question
Can you help me I keep getting error on my program Can you help me what I did wrong or write a new code It's for Visual Basic 2015 Elself intSelection 3 Then Elself intSelection Else 1blStatus. Text Pi times radius squared times height 1b1 Status . Text -We11/ okay then, good bye!" 1b1status . Text "Your sel eettonwas not recognized. 4 Then End If Programming Challenges 1. Larger and Smaller Create an application that allows the user to enter two-integers ou a form similar to the one shown in Figure 4-33. The application should determin larger than the other, or it should d paring the numbers, use the TcyParse method to verify that both inputs are valid integers. If an error is found, display an appropriate message to the user. Use a Label control to display all messages. The Exit button should close the window. al. Before com- gure 4-33 Larger and Smaller form Entor Two Intogors Comparo Ext 2. Roman Numeral ConverterExplanation / Answer
Hi,
TryParse will retrun true if the parsing to integer is successful. Please consider below code for verifying if the parsing is true or false. It is working module.
Please follow below steps-
1. Remove below lines from your code-
number1=CInt(txtA.Text)
number2=CInt(txtB.Text)
2. Now use below code for the if ..else logic-
Dim intRes As Integer
Dim result1 As Boolean = Int32.TryParse(txtA.Text, intRes)
Dim result2 as Boolean =Int32.TryParse(txtB.Text, intRes)
If result1=true and result2=true Then
<<<Put your code to compare numbers>>>
Else
lblresult.Text="Invalid Data"
End If
Sample code- I have written this for you to understand the functionality
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim value As Integer
Dim number As Integer
Dim result As Boolean = Int32.TryParse(TextBox1.Text, number)
If result = True Then
Console.WriteLine("Converted '{0}' to {1}.", TextBox1.Text, number)
MsgBox("Translation successful")
Else
Console.WriteLine("Attempted conversion of '{0}' failed.")
MsgBox("Translation Unsuccessful")
End
Thanks and Regards,
Vinay Prakash Singh