473,406 Members | 2,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to declare a string?

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

Nov 19 '05 #1
3 1207
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

Nov 19 '05 #2
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****************@TK2MSFTNGP12.phx.gbl...
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

Nov 19 '05 #3
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****************@TK2MSFTNGP12.phx.gbl...
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

Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Lance Geeck | last post by:
I have many items that I lifted off from Microsoft's website several years ago. These samples were in VB6. I now want to convert an application to VB.NET. I am getting an error that says "As Any...
0
by: Lance Geeck | last post by:
I have many items that I lifted off from Microsoft's website several years ago. These samples were in VB6. I now want to convert an application to VB.NET. I am getting an error that says "As Any...
2
by: Lance Geeck | last post by:
I have many items that I lifted off from Microsoft's website several years ago. These samples were in VB6. I now want to convert an application to VB.NET. I am getting an error that says "As Any...
1
by: marfi95 | last post by:
I'm trying to call methods in a C++ dll from vb.net that is not a .com component. I've read I can just use regular Declare statements just as you do in VB6 except that some of the types need to...
0
by: roamnet | last post by:
hi i created database file with .mdf extention ,sql server as a source and use grid view to display data there're no problem in data retrieve and display,but i want to edit it or insert new...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.