A sub problem?

Why dont you just call the last sub from the middle one and send it the variable? Also, are these all in the same form/module? If so you could dim a private for the form/module and just set the text to that on the first passing of the variable. Hope that makes sense.
 
It make some sens

The modul Is in one file and the class is in another. So you mean I should send the string from the Shared Sub to the Public Sub


I forget to name the sub in the previous post but it sholud be, Public Sun Run() for exampel.
And to "send" the stringe should like this..

-------
Shared Sub Getvalue(ByVal texta As String)

Console.Write(texta)
Run(texta)

End Sub




Public Sub Run(ByVal text2 As String)

Console.Write(text2)

End Class

but it dosent work.... I got this error msg on Run(texta)


Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class.


// Ready for more help :-)
 
Did you try a dim statement in the shared sub so that you are not passing the actual instance variable? Like:

Shared Sub Getvalue(ByVal texta As String)

dim newText as string = texta

Console.Write(texta)
Run(newText)

End Sub

I think that should work.
 
Maybe It should work, but it dosent. Can you or somebody else try.... just to put in this code....
-----
Public Class Class1


Shared Sub Test()

Dim Texts As String = "To public Sub"

Console.Write(Texts)
Run(Texts)

End Sub


Public Sub Run(ByVal text2 As String)

Console.Write(text2)
Console.Write(Texts)


End Sub

End Class

-----
I want to send a string from a shared sub to public or that I can use the variabel in Shared Sub in my Public Sub...

Thanksful for all help!!!!
//Rivermen
 
The problem you are having is that GetValue is a shared class member and Run isnt.

Shared members of a class work without a specific instance i.e. you could do something like
Code:
Class1.GetValue("dsafsdafsadf")

but non-shared members need a specific instance to be created i.e.
Code:
dim c as new class1
c.Run("ewrewrwerwerewr")

Is there any reason GetValue is shared? It may help if you gave a bit more background on what you are trying to do though.
 
ohhhhh tnx you saved me :-) The Dim C as New class1 made it work.

The reason I have the GetValue Shared is that i want to send a string from a seperat modul1 to a class, and the only way i get it to work was with a Shared Sub in the class1.

Maybe it will work another way... but i dont know.... maybe you got some answer for that to :-)

Thanks again to your both that help me....

// Rivermen
 
Back
Top