Write a Vb.net program to add two TextBoxes, two Labels and one button at runtime. Accept two numbers in textboxes and handle DivideByZeroException.
slip No 6
Public Class Form1
Dim t1, t2 As New TextBox
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Controls.Add(t1)
Controls.Add(t2)
t1.Left = 200
t1.Top = 50
t2.Left = 200
t2.Top = 100
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ans, n1, n2 As Double
n1 = CInt(t1.Text)
n2 = CInt(t2.Text)
Try
ans = n1 \ n2
Catch ex As DivideByZeroException
MessageBox.Show("Divide By Zero Exception Caughted")
Finally
MsgBox(ans)
End Try
End Sub
End Class
Nice✔✔
ReplyDelete