Here this program we create class and there class object and also create method overloading in vb.net.Let's understand by program.
ClassBook.vbv
Public Class Book
Public Overloads Sub BookData(ByVal id As Integer, ByVal name As String, ByVal isbn As Integer)
MsgBox("Book Details..." & vbNewLine & "ID " & id & vbNewLine & "Name " & name & vbNewLine & "ISBN " & isbn)
End Sub
Public Overloads Sub BookData(ByVal price As Integer, ByVal auname As String)
MsgBox("Book Details..." & vbNewLine & "Price " & price & vbNewLine & "Author Name " & auname)
End Sub
End Class
Form1.vbPublic Overloads Sub BookData(ByVal id As Integer, ByVal name As String, ByVal isbn As Integer)
MsgBox("Book Details..." & vbNewLine & "ID " & id & vbNewLine & "Name " & name & vbNewLine & "ISBN " & isbn)
End Sub
Public Overloads Sub BookData(ByVal price As Integer, ByVal auname As String)
MsgBox("Book Details..." & vbNewLine & "Price " & price & vbNewLine & "Author Name " & auname)
End Sub
End Class
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim b1 As New Book
Dim id, isbn, price As Integer
Dim name, authorName As String
id = Val(TextBox1.Text)
isbn = Val(TextBox2.Text)
name = TextBox3.Text
authorName = TextBox4.Text
price = Val(NumericUpDown1.Value)
Call b1.BookData(id, name, isbn)
Call b1.BookData(price, authorName)
End Sub
End Class
DESIGNINGPrivate Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim b1 As New Book
Dim id, isbn, price As Integer
Dim name, authorName As String
id = Val(TextBox1.Text)
isbn = Val(TextBox2.Text)
name = TextBox3.Text
authorName = TextBox4.Text
price = Val(NumericUpDown1.Value)
Call b1.BookData(id, name, isbn)
Call b1.BookData(price, authorName)
End Sub
End Class
Comments
Post a Comment