In: Computer Science
NOTE: This is done using Visual Basic.
Create an application named You Do It 2. Add a text box, a label, and a button to the form. Enter the following three Option statements above the Public Class clause in the Code Editor window: Option Explicit On, Option Strict Off, and Option Infer Off. In the button’s Click event procedure, declare a Double variable named dblNum. Use an assignment statement to assign the contents of the text box to the Double variable. Then, use an assignment statement to assign the contents of the Double variable to the label. Save the solution and then start and test the application. Stop the application. Finally, change the Option Strict Off statement to Option Strict On and then use what you learned in this Focus lesson to make the necessary modifications to the code. Save the solution and then start and test the application. Close the solution.
Windows Forms Application project in C# is created using visual studio with name "You_Do_It".Below is the details.
Form1.vb[Design] :
Form1.vb :
'three Option statements
Option Explicit On
Option Strict Off
Option Infer Off
Public Class Form1
'display button click
Private Sub btnContents_Click(sender As Object, e As EventArgs)
Handles btnContents.Click
'declaring variable of type double that is dblNum
Dim dblNum As Double
'taking text entered by user and assign to the variable
dblNum
dblNum = Double.Parse(txtContents.Text)
'display variable’s contents in the label
lblDisplayContents.Text = dblNum
End Sub
End Class
=======================================
Output :
NOTE :
'three Option statements
Option Explicit On
Option Strict On
Option Infer Off
Public Class Form1
'display button click
Private Sub btnContents_Click(sender As Object, e As EventArgs)
Handles btnContents.Click
'declaring variable of type double that is dblNum
Dim dblNum As Double
'taking text entered by user and assign to the variable
dblNum
dblNum = Double.Parse(txtContents.Text)
'display variable’s contents in the label
'need to explicitly typecast from double to string
lblDisplayContents.Text = dblNum.ToString()
End Sub
End Class