Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How to declare a string?

Reply
Thread Tools

How to declare a string?

 
 
Shapper
Guest
Posts: n/a
 
      10-13-2005
Hello,

I am declaring a String Array as follows:

Dim labeltext As String()
Select Case culture
Case "pt-PT"
labeltext = {"A...", _
"B...", _
"C...", _
"D..."}
Case "en-GB"
Case Else
End Select

However it's not working?

What am I doing wrong?

I know it would work if I would do as follows:
Dim labeltext As String = {"A...", _
"B...", _
"C...", _
"D..."}

Thanks,
Miguel

 
Reply With Quote
 
 
 
 
=?Utf-8?B?RGF2aWQgQW50b24=?=
Guest
Posts: n/a
 
      10-13-2005
You have to do something like:
labeltext = New String() {"A...", _
"B...", _
"C...", _
"D..."}

Array declarations allow you to omit the "New String[]" part, but
assignments do not.

--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB.NET to C# Converter
Instant VB: C# to VB.NET Converter
Instant J#: VB.NET to J# Converter
Clear VB: Cleans up outdated VB.NET code


"Shapper" wrote:

> Hello,
>
> I am declaring a String Array as follows:
>
> Dim labeltext As String()
> Select Case culture
> Case "pt-PT"
> labeltext = {"A...", _
> "B...", _
> "C...", _
> "D..."}
> Case "en-GB"
> Case Else
> End Select
>
> However it's not working?
>
> What am I doing wrong?
>
> I know it would work if I would do as follows:
> Dim labeltext As String = {"A...", _
> "B...", _
> "C...", _
> "D..."}
>
> Thanks,
> Miguel
>
>

 
Reply With Quote
 
 
 
 
Karl Seguin
Guest
Posts: n/a
 
      10-13-2005
labletext = new String() {"..", ",,")

you could also use an arraylist if you wanted to.

dim labelTExt as new ArrayList()
....
labelText.Add("..")
labelText.Add("..")
labelText.Add("..")

and convert it to a string array

dim arr as string() = ctype(arr.ToArray(gettype(string)), string())

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!



"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
news:OL%(E-Mail Removed)...
> Hello,
>
> I am declaring a String Array as follows:
>
> Dim labeltext As String()
> Select Case culture
> Case "pt-PT"
> labeltext = {"A...", _
> "B...", _
> "C...", _
> "D..."}
> Case "en-GB"
> Case Else
> End Select
>
> However it's not working?
>
> What am I doing wrong?
>
> I know it would work if I would do as follows:
> Dim labeltext As String = {"A...", _
> "B...", _
> "C...", _
> "D..."}
>
> Thanks,
> Miguel
>



 
Reply With Quote
 
Ken Cox [Microsoft MVP]
Guest
Posts: n/a
 
      10-13-2005
I think the assignment shortcut has to be used in one statement. You could
use this if they are separate:

Dim labeltext(4) As String
Select Case Culture
Case "pt-PT"
labeltext(0) = "A..."
labeltext(1) = "B..."
labeltext(2) = "C..."
labeltext(3) = "D..."
Case "en-GB"
Case Else
End Select

Ken
MVP [ASP.NET]

"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
news:OL%(E-Mail Removed)...
> Hello,
>
> I am declaring a String Array as follows:
>
> Dim labeltext As String()
> Select Case culture
> Case "pt-PT"
> labeltext = {"A...", _
> "B...", _
> "C...", _
> "D..."}
> Case "en-GB"
> Case Else
> End Select
>
> However it's not working?
>
> What am I doing wrong?
>
> I know it would work if I would do as follows:
> Dim labeltext As String = {"A...", _
> "B...", _
> "C...", _
> "D..."}
>
> Thanks,
> Miguel
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I declare subpackages? Derek Graham VHDL 7 09-18-2004 06:20 PM
How do we declare a signed integer? Kwaj VHDL 2 05-06-2004 03:07 PM
When to use 'As New' to declare an object Ritu ASP .Net 2 08-13-2003 05:47 PM
Error: Must Declare Variable Boris Zakharin ASP .Net 2 07-22-2003 01:04 AM
how to declare session variable in global.asax file khawar ASP .Net 1 07-10-2003 08:03 PM



Advertisments