Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8704243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:03:15+00:00 2026-06-13T03:03:15+00:00

I have a problem with getting variable from another class and cannot understand what

  • 0

I have a problem with getting variable from another class and cannot understand what to do with interface`s functions which have already existed in another class.

What I have:

Form where clicking on a button I should see reversed string:
(I want to call pooraja.StringReverse which is below)

 Private Sub btnPoora1_Click(sender As System.Object, e As System.EventArgs) _
        Handles btnPoora1.Click

        'Dim text As PrjTekstiPooraja.ITeisendused = New PrjTekstiPooraja.CtekstiPooraja
        Dim text As PrjTekstiPooraja.ITeisendused = New PrjTekstiPooraja.CtekstiPooraja
        Dim pooraja As PrjTekstiPooraja.ITeisendused = New PrjTekstiPooraja.CAlgrotimilinePooraja

        text.strText = txtSisendTekst.Text
        txtValjundTekst1.Text = pooraja.stringReverse

        text.intStart = 1
        text.intEnd = Len(txtSisendTekst.Text)

        ascFSymbol.Text = text.ascFirstSymbol
        ascLSymbol.Text = text.ascLastSymbol()
    End Sub

CtekstiPooraja:
(Thiss class will be used to store data.Under data I mean strPooratavText. Data will be used in CAlgoritmilinePooraja)

    Public Class CtekstiPooraja
    Implements ITeisendused

    Public intStartSymbol As Integer
    Public intEndSymbol As Integer
    Public strPooratavText As String

    Private Property intEnd As Integer Implements ITeisendused.intEnd
        Get
            Return intEndSymbol
        End Get
        Set(ByVal value As Integer)
            intEndSymbol = value
        End Set
    End Property

    Private Property intStart As Integer Implements ITeisendused.intStart
        Get
            Return intStartSymbol
        End Get
        Set(ByVal value As Integer)
            intStartSymbol = value
        End Set
    End Property

    Public Function pooraText() As String Implements ITeisendused.pooraText
        Return StrReverse(strPooratavText)
    End Function

    Public Property strText As String Implements ITeisendused.strText
        Get

            Return strPooratavText
        End Get
        Set(ByVal value As String)
            strPooratavText = value
            MsgBox(strPooratavText)
        End Set
    End Property

    Public Sub teisendaText(ByRef strSisendText As String) Implements ITeisendused.teisendaText
        strPooratavText = StrReverse(strSisendText)
    End Sub

    Public Function ascFirstSymbol() As String Implements ITeisendused.ascFirstSymbol
        Return Asc(GetChar(strPooratavText, intStartSymbol))
    End Function

    Public Function ascLastSymbol() As String Implements ITeisendused.ascLastSymbol
        Return Asc(GetChar(strPooratavText, intEndSymbol))
    End Function

    Public Function stringReverse() As String Implements ITeisendused.stringReverse
        Return Nothing
    End Function



End Class

CAlgrotimilinePooraja:
(This class will be called by form button. There I need to use stringReverse function with data from CtekstiPooraja. The problem is that everywhere is used the same interface and there is some functions and procedures from this interface which isnt necessary. I dont know what value should return these unused functions/procedures. Just using “return Nothing or return 0/ “” is bad idea, may be there is possible somehow referenceto to CTekstiPooraja functions/procedures variables”)

Public Class CAlgrotimilinePooraja
    Implements ITeisendused

    Private x As New PrjTekstiPooraja.CtekstiPooraja
    Public Function stringReverse() As String Implements ITeisendused.stringReverse
        MsgBox(x.strPooratavText)
        Dim i As Integer = 0
        Dim j As Integer
        Dim characters(j) As Char
        Dim newString(j) As Char
        characters = x.strPooratavText.ToCharArray()
        newString = x.strPooratavText.ToCharArray()

        Do While i <= j - 1
            newString(i) = characters(j - 1)
            newString(j - 1) = characters(i)
            i += 1
            j -= 1
        Loop
        Return newString
    End Function

    Public Function ascFirstSymbol() As String Implements ITeisendused.ascFirstSymbol
        Return x.ascFirstSymbol()
    End Function

    Public Function ascLastSymbol() As String Implements ITeisendused.ascLastSymbol
        Return Nothing
    End Function

    Public Property intEnd As Integer Implements ITeisendused.intEnd
        Get
            Return x.intEndSymbol
        End Get
        Set(ByVal value As Integer)

        End Set
    End Property

    Public Property intStart As Integer Implements ITeisendused.intStart
        Get
            Return x.intStartSymbol
        End Get
        Set(ByVal value As Integer)

        End Set
    End Property

    Public Function pooraText() As String Implements ITeisendused.pooraText
        Return x.pooraText()
    End Function

    Public Property strText As String Implements ITeisendused.strText
        Get
            Return x.strPooratavText
        End Get
        Set(ByVal value As String)

        End Set
    End Property

    Public Sub teisendaText(ByRef strSisendText As String) Implements ITeisendused.teisendaText
        x.strPooratavText = StrReverse(strSisendText)
    End Sub
End Class

MyInterface:

Public Interface ITeisendused

    Property intStart As Integer
    Property intEnd As Integer
    Property strText As String

    Function pooraText() As String
    Function ascFirstSymbol() As String
    Function ascLastSymbol() As String
    Function stringReverse() As String
    Sub teisendaText(ByRef strSisendText As String)

End Interface

I cannot understand how to get variable strPooratavText from CTekstiPooraja to CAlgrotimilinePooraja. Usually that instancewhich I create worked but not now. And I cannot understand what to do with already existed function and procedures in CAlgoritmilinePooraja when the same function and procedures has in another class. Maybe, it is possible to reference them somehow to existed functions/procedures in CTekstiPooraja? Could you explain me how to id, already tired to surf Internet to find a solution for it, have already try a lot.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T03:03:16+00:00Added an answer on June 13, 2026 at 3:03 am

    Well, I think you have a fundamental problem with understanding interfaces. They describe data and behavior, it should be extremely rare to want to implement part of an interface.

    That said, if you do want to implement part of an interface, instead of returning bogus data, throw an exception for behavior you don’t implement.

    Your specific problem is that CAlgoritmilinePooraja works on an instance of CtekstiPooraja, but it creates a new instance instead of using an existing one. Add

    Sub New(incomingX as CtekstiPooraja)
      x = incomingX
    End Sub
    

    to CAlgoritmilinePooraja. And then in your event, use….

    Dim text As PrjTekstiPooraja.CtekstiPooraja = New PrjTekstiPooraja.CtekstiPooraja
    text.strText = txtSisendTekst.Text
    Dim pooraja As PrjTekstiPooraja.ITeisendused = New PrjTekstiPooraja.CAlgrotimilinePooraja(text)
    

    That is the minimum change to your design that gets what you want to happen to happen but it’s problably not what you should do. Other than implementing strReverse, CtekstiPooraja seems to be what you want, CAlgrotimilinePooraja looks to do just one thing, the actual string reversal.

    I would move the implementation of strReverse into CtekstiPooraja, and then eliminate CAlgrotimilinePooraja.

    PS I would try to stick to English for class names as well as functions and variables.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

reference from: Merging Variable PHP I have problem with $_POST getting blank null after
I have a problem where a method is getting an undefined variable error, even
This is a follow up from Creating a class which inherits from another class
I just started a graphical C++ course and I have problem getting an overview
I have a problem getting password_Reset_confirm bit working. url: (r'^password_reset/$', 'django.contrib.auth.views.password_reset'), (r'^password_reset_done/$', 'django.contrib.auth.views.password_reset_done'), (r'^password_reset_confirm/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$',
I have a problem getting the right Price for a product based on Effectivity
I have a problem getting boost::multi_index_container work with random-access and with orderd_unique at the
I have a problem getting a private method using reflection. Even with BindingFlags.NonPublic and
I have this problem getting my newly created php project on Netbeans work on
I'm using jqGrid and I have a problem getting Dynamic Linq to work. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.