Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to acess to a public class

Status
Not open for further replies.

curiousvbnet

Programmer
Apr 6, 2007
40
FR
Hi,

i have created in the same project two classes ;the first onis called TreeView_MT_GEN_SPE_ASSOCIEs and the second one is called candidat_descripteur.
In the TreeView_MT_GEN_SPE_ASSOCIES class i have created a public function called sansaccent and i want to use it in the candidat_descripteur class.
But i see i have an error message when i use it in the candidat_descripteur form(a reference to a non shared member requires an object reference').

could you tell me what i need to do to access without any problem to the sansaccent funtion.

Thanks a lot for all your help.
Best regards.
Nathalie

Here is the code i use until now
Code:
Imports System.Windows.Forms
Imports System.IO
Imports System.Drawing.Font
Imports System.Xml
Imports Application_Windows_Thesaurus.TreeView_MT_GEN_SPE_ASSOCIES


Public Class candidat_descripteur
    Inherits System.Windows.Forms.Form


    Private m_objConn As SqlConnection
    Private objDS6 As DataSet
    Private objDA6 As SqlDataAdapter



    Public WriteOnly Property Connection() As SqlConnection
        Set(ByVal Value As SqlConnection)
            m_objConn = Value
        End Set
    End Property

    [blue]Private Sub Enreg_cd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Enreg_cd.Click[/blue]
        Dim strInsert_cd As String, objInsertNew_cd As SqlCommand, strSQLTERMES_Cd As String, drTerme As DataRow
        Dim termecd_existe As Boolean
        strSQLTERMES_Cd = " select Lib_CD from CANDIDAT_DESCRIPTEUR"

        strInsert_cd = "INSERT into CANDIDAT_DESCRIPTEUR(Lib_CD) values ('"
        strInsert_cd &= Replace(txtbox_cd.Text, "'", "''") & "')"

        m_objConn.Open()
        objInsertNew_cd = New SqlCommand(strInsert_cd, m_objConn)
        objInsertNew_cd.ExecuteNonQuery()
        m_objConn.Close()

     [green]   'il faut verifier si ce terme n'existe pas déjà dans la table des candidats descripteurs[/green]
        objDS6 = New DataSet
        objDS6.Tables("TERMES").Clear()
        objDA6 = New SqlDataAdapter(strSQLTERMES_CD, m_objConn)
        objDA6.Fill(objDS6, "TERMES_CD")

        For Each drTerme In objDS6.Tables("TERMES_CD").Rows

            Dim strLibelle5, strLibelle6 As String

            strLibelle5 = Replace(txtbox_cd.Text, " ", "")

            strLibelle6 = Replace(strLibelle5, "-", "")

            Dim libterme5, libterme6 As String
            libterme5 = Replace((CType(drTerme.Item("Lib_CD"), String).ToUpper), " ", "")
            libterme6 = Replace(libterme5, "-", "")
                       If SansAccent(strLibelle6.ToUpper) = SansAccent(libterme6) Then<-[blue]here i receive the message about the sansaccent function[/blue]
                termecd_existe = True


            End If
        Next



      
    End Sub

    Private Sub Annul_saisie_CD_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Annul_saisie_CD.Click

       
    End Sub



End Class

 
SansAccent must be declared as Public Shared Function in TreeView_MT_GEN_SPE_ASSOCIES .


Hope it helps
 
Thanks a lot for your help.
Is it the same for a sub?

Thanks for your help.
Nathalie
 
Yes,

the shared keyword lets you access what's declared as shared without instanciating your class.

Code:
YourClass.SharedFunctionOrSubOrPropertyOrVariable

Hope it's clear.
 
thanks a lot , i know it very well,it is a very good reference but you are right ,i didn't yet have a look at this part of its programm.

thanks for all.
Nathalie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top