Code for Implementing Class in VB.NET


Here there is a program code that would help you in implementing class in VB.NET.

PROGRAM CODE FOR IMPLEMENTING CLASS IN VB.NET




Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a As New arithmetic
Dim c As Integer
c = TextBox1.Text
a.evenodd(c)
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim c As New arithmetic
Dim a As Double
Dim b As Double
a = TextBox1.Text
b = TextBox2.Text
c.swap(a, b)
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim y As New arithmetic
Dim x As Integer
x = TextBox1.Text
y.revofnum(x)
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim a As New arithmetic
Dim b As Integer
b = TextBox1.Text
a.prime(b)
End Sub
End Class



Public Class arithmetic
Function evenodd(ByVal b As Integer) As Integer
Dim rem1 As Integer
rem1 = b Mod 2
If rem1 = 0 Then
MsgBox("even")
Else
MsgBox("Odd")
End If

End Function
Function swap(ByRef x As Double, ByRef y As Double) As Double
Dim z As Double
z = x
x = y
y = z
MsgBox("number after swapping are " & x & " and " & y)


End Function
Function revofnum(ByVal a As Integer) As Integer
Dim rem1, sum1 As Integer
sum1 = 0
While a > 0
rem1 = a Mod 10
sum1 = sum1 * 10 + rem1
a = a \ 10
End While
MsgBox("reverse of number is " & sum1)

End Function
Function prime(ByVal a As Integer) As Integer
Dim i, j, k As Integer
i = 2
j = 0
While i < a
k = a Mod i
If k = 0 Then
j = 1
End If
i += 1
End While
If j = 0 Then
MsgBox("number is prime")
Else
MsgBox("number is not prime")
End If
End Function

End Class


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: