Example :: Call Class Inherits Class

Class1.vb

Imports System.Data
Imports System.Data.SqlClient

Public Class Class1
    Public sql As String
    Public da As SqlDataAdapter
    Public ds As New DataSet
    Public conn As New SqlConnection("connectionstring")
End Class

Class2.vb

Public Class Class2
    Inherits Class1

    Public Function displaymsg(ByVal value As String)
        Return value
    End Function
End Class

Form1.vb

Imports System.Data
Imports System.Data.SqlClient

Public Class Form1

    Dim x As New Class2

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        x.sql = "select * from table"
        x.da = New SqlDataAdapter(x.sql, x.conn)
        x.da.Fill(x.ds, "dt")
        DataGridView2.DataSource = x.ds.Tables("dt")

        MsgBox(x.displaymsg("Hello World"))
    End Sub
End Class

Comments

Popular posts from this blog

การตั้งเวลาระหว่าง Server และ Client

วิธีตั้งค่า NTP บน Primary Domain Controller

Installation and Run Node.JS on IIS