Programming Environment and Writing Programs
Programming Environment and Writing Programs
Page 1 of 20
Relational Database Management systems
Page 2 of 20
Relational Database Management systems
10.Click OK button.
11. The Form1 appears on the screen.
Page 3 of 20
Relational Database Management systems
Code
Window
NOTE:
Page 4 of 20
Relational Database Management systems
Page 5 of 20
Relational Database Management systems
Page 6 of 20
Relational Database Management systems
Dim a, b As Double
a = Val(txtNum1.Text)
b = Val(txtNum2.Text)
MsgBox("Sum of numbers is " & a + b, , "Addition")
Page 7 of 20
Relational Database Management systems
Implicit Conversion
8. Double click the command button and type the following code
in the procedure body.
Page 8 of 20
Relational Database Management systems
14. To exactly find the data type of the doubleResult, add this
line of the code at the end.
MsgBox(doubleResult.GetType.ToString)
15. Run this application, and press the command button, we get
this result.
16. The message box shows the type of the data which
doubleResult has.
Explicit Conversion
5. Double click the button and type the following code in the
procedure body.
Page 9 of 20
Relational Database Management systems
Page 10 of 20
Relational Database Management systems
5. Double click the new button and type the following code in
its procedure body.
6. Here we have converted the stringVal variable into Long using the convert
method and added the result to the integerVal and saved into the
longResult variable of type Long.
7. To test the result run the application and press the button.
Page 11 of 20
Relational Database Management systems
Page 12 of 20
Relational Database Management systems
Convert Temperature in oF to oC
Page 13 of 20
Relational Database Management systems
Try
Dim a As Double
a = Math.Round((Convert.ToDouble(TextBox1.Text) -
32 ) * 5 / 9, 2)
Label2.Text = "Temperature in degree Centigrade = " +
a.ToString()
Catch ex As Exception
TextBox1.Text = 0
End Try
Convert Temperature in oC to oF
Page 14 of 20
Relational Database Management systems
Try
square()
Catch ex As Exception
TextBox1.Text = 0
End Try
Page 15 of 20
Relational Database Management systems
Checking Number
A Simple Calculator
Page 16 of 20
Relational Database Management systems
Try
lblRes.Text = ""
lblRes.Text = "Sum = " & CDbl(txtOp1.Text) + Dbl(txtOp2.Text)
Catch ex As Exception
MsgBox("Enter correct data!")
End Try
Page 17 of 20
Relational Database Management systems
Page 18 of 20
Relational Database Management systems
Try
Label3.Text = "List of numbers from " & txtStart.Text & " to " &
txtEnd.Text & " is:"
Dim i As Integer
ListBox1.Items.Clear()
If CInt(txtStart.Text) > CInt(txtEnd.Text) Then
MsgBox("Start Value must be less than the End Value",
MsgBoxStyle.Information, "Enter correct values")
Else
For i = CInt(txtStart.Text) To CInt(txtEnd.Text) Step 1
ListBox1.Items.Add("Count " & i)
Next
End If
Catch ex As Exception
MsgBox("Enter complete data!", MsgBoxStyle.OKOnly, "Incomplete Data")
End Try
8. Code ensures that start value is always less than the end
value by an if condition.
9. We have also used a try … catch block to encounter any
other error which may halt the program execution.
10.Run application by pressing F5.
11.Enter two numbers in the textboxes and press the command
button.
12. Desired list of numbers will be obtained in the listbox.
Page 19 of 20
Relational Database Management systems
Page 20 of 20