VB question

Author
Discussion

TheExcession

Original Poster:

11,669 posts

252 months

Tuesday 11th October 2005
quotequote all
please help... I frigging hate VB -

I need an array of static final strings in VB (.NET)

Normally in C/Java I'd do

public final static string[] = new string {
"s1",
"s2",
"s3",
"s4"
};

How do I do the same in VB?

I know google is my friend - but after searching te top 20 pages I still didn't get an answer :(

many thanks
Ex

TheExcession

Original Poster:

11,669 posts

252 months

Tuesday 11th October 2005
quotequote all
Don said:
Why not just

Dim s(10) As String

s(1) = "s1"
s(2) = "s2"

etc?

OK. So you want to protect the strings from accidental overwrites - but hey! Its VB.

Hopefully a VB.NET person will be along with exactly what you want...

Have you tried looking up the syntax in C#?


Thanks Don

Well, Oh , I originally wrote the APP in C# and now I'm having to rewrite the whole bloody lot in VB so that 'other' people can maintain it.... still at least I'm getting paid to do it.

Did I mention that I hate coding VB almost as much as I hate HTML

TheExcession

Original Poster:

11,669 posts

252 months

Wednesday 12th October 2005
quotequote all
pdV6 said:

Don said:

Why on earth a client would pay you to re-write a C# app in VB is beyond me


That was my first thought!


Strange world init?

TheExcession

Original Poster:

11,669 posts

252 months

Wednesday 12th October 2005
quotequote all
ok, I'm still struggling with this -

Namespace I4Spots.spotmaps
Public Class spotstates
Public saSPOTSTATES As String() = {"Any", "G", "GL", "GLM", "GLMC"}
End Class
End Namespace

but saSPOTSTATES is not visible as a static member - as needed to populate a combobox with the array:

ComboBoxStates.Items.AddRange(spotstates.saSPOTSTATES)


What am I doing wrong?

Tried
Static saSPOTSTATES As String() = {"Any", "G", "GL", "GLM", "GLMC"} - tells me static is not a valid member definition?

It won't let me use Const either?

Jesus, how clumsy is this shit?

TheExcession

Original Poster:

11,669 posts

252 months

Wednesday 12th October 2005
quotequote all
RIchardD said:
www.dnzone.com/ShowDetail.asp?NewsId=356

Shows some differences between C# and vb.net

Static seems to mean different things between the two languages

Hallelujah, thanks Richard:

Public Class spotstates

Shared saSPOTSTATES As String() = {"Any", "G", "GL", "GLM", "GLMC"}

Public Shared Function getStateStrings() As String()
Return saSPOTSTATES
End Function
End Class

seems to have done it!