Translating from Java to .Net

hi!

Could anyone translate this java code into vb code for me?
1.
I use this class to store String values that I use in all my aspx.vb- classes. When written like this in java, I don't have to create new instances of the class to get the values from the attributes. I want to do the same in vb. But how?
public class MyClass {
public static final String CONTACT_GET = "contactGet";
}
To get value in java classes:
String value = MyClass.CONTACT_GET;

2.
Second question. Simply just need a translation.
String test = "this is a \"big\" test";

regards
asgi
-1
asgi
10/12/2004 8:03:55 AM
asp.net.getting-started 91979 articles. 2 followers. Follow

10 Replies
355 Views

Similar Articles

[PageSpeed] 10

You may try this:


Public Class MyClass
Public Shared CONTACT_GET As String = "contactGet"
End Class

Second one

Dim test As String = "this is a \big\ test"

This posting is provided "AS IS" with no warranties, and confers no rights.
-1
jimmym
10/12/2004 2:16:45 PM
Jimmy wouldn't the 'second one' in vb be this:


Dim test As String = "this is a " & Microsoft.VisualBasic.ControlChars.Quote & "big" & Microsoft.VisualBasic.ControlChars.Quote & " test"

And you can also make this simplier by doing this:

Dim _q As String = Microsoft.VisualBasic.ControlChars.Quote
Dim test As String = "this is a " & _q & "big" & _q & " test"

wouldnt that be correct?
-1
CGGamer
10/12/2004 2:44:00 PM
Hi

Thanx for answering so fast. Meanwhile, I found out the answers myself:
1.
public class MyClass
private Const CONTACT_GET as String = "contactGet"

2.
dim test as string = "this is a ""big"" test"

regards
asgi
-1
asgi
10/12/2004 8:11:20 PM
I don't have to create new instances of the class to get the values from the attributes.

Your first one cannot do this.
This posting is provided "AS IS" with no warranties, and confers no rights.
1
jimmym
10/12/2004 8:14:13 PM

Sorry, forgot to write that the attribute have to be public:
public class MyClass
public Const CONTACT_GET as String = "contactGet"


regards
asgi
1
asgi
10/12/2004 9:22:58 PM
i think you would still need to add Shared like:

public shared Const CONTACT_GET as String = "contactGet"
correct me if i am wrong.
1
CGGamer
10/12/2004 9:56:28 PM
That's right, if you don't want to create an instances of the class, you have to use "Shared" in vb.net.
This posting is provided "AS IS" with no warranties, and confers no rights.
-1
jimmym
10/12/2004 10:30:08 PM
Are you sure? I use Const all the time.
Picky
1
pickyh3d
10/13/2004 12:29:35 AM

I'm using the :
public Const CONTACT_GET as String = "contactGet"
...and it works fine.... I don't have to use "shared" keyword because the "Const" statement are shared by defalut.

regards
asgi
-1
asgi
10/13/2004 6:38:58 AM
wow. i didnt no that.

but than again it does make sense since Const never change.
anyway sorry for confusing you if i did.
-1
CGGamer
10/13/2004 2:30:30 PM
Reply: