473,796 Members | 2,801 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"Basic Question"

What is the difference between these declarations:
Dim strMyData() as string

and

Dim strMyData as string()

-Peter

Nov 21 '05 #1
12 1275
I believe they are equivalent. I think the second has been deprecated.
Although, it works fine in VB 2005 beta 1.

Dim strMyData() As String = {"a", "b", "c"}
Dim strMyData As String() = {"a", "b", "c"}

Greg
"pmclinn" <pe***@mclinn.c om> wrote in message
news:11******** *************@f 14g2000cwb.goog legroups.com...
What is the difference between these declarations:
Dim strMyData() as string

and

Dim strMyData as string()

-Peter

Nov 21 '05 #2
Peter,

As Greg said they have equal results,

However
dim str(10) as String goes and
dim str() as String(10) does not go

A little bit confusing is that in a function or other places where you need
the type you will write:
private function myfunction (byval str as String()) As string()
Ctype(mytype, String())

I hope this helps?

Cor

"pmclinn" <pe***@mclinn.c om>
What is the difference between these declarations:
Dim strMyData() as string

and

Dim strMyData as string()

-Peter

Nov 21 '05 #3
"Cor Ligthert" <no************ @planet.nl> schrieb:
As Greg said they have equal results,

However
dim str(10) as String goes and
dim str() as String(10) does not go


But 'Dim astr As String(10) {}' will work.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #4
Herfried,
But 'Dim astr As String(10) {}' will work.


Thanks I did not know that.
(And I will never use that)

:-)

Cor
Nov 21 '05 #5
Don't write that one off to quickly Cor.

Although it's not quite the same, the following can be very useful.

Dim astr() As String
Nov 21 '05 #6
"Stephany Young" <noone@localhos t> schrieb:
Although it's not quite the same, the following can be very useful.

Dim astr() As String
.
.
.
astr = New String(10) {}


You could use 'ReDim astr(10)' instead of the line above, which is IMO the
preferred method because it uses VB.NET's own array syntax.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #7
Stephany,

I have the opinion that for a fixed array the array is the best
For a dynamimc array every Ilist or Icollection implementing
array/collection, where the arraylist is my favorit.

Cor
Nov 21 '05 #8
Agreed Herfied. I was pointing out a valid alternative rather than
advocating it's use.

That said, the alternative does have one useful feature and that is to
populate the array at the same time as declaring and/or 'ReDim'ing it:

Dim astr() As String = New String(10) {"1", "4", "7" ... "A", "D"}
Nov 21 '05 #9
Dim strMyData() as string

means that you are initializing an array of strings

Dim strMyData as string()

is simply wrong syntax. The open and close parentheses at the end of the
statement signifies that you are providing reference to the class
through the default constructor of the class but since you are not using
it with the New keyword it is wrong syntax.

You can use Dim strMyData as New SomeClass(), which means that you are
creating an instance called strMyData and initializing the object
through the default constructor of the class.

with regards,
J.V.Ravichandra n
- http://www.geocities.com/
jvravichandran
- http://www.411asp.net/func/search?
qry=Ravichandra n+J.V.&cob=aspn etpro
- http://www.southasianoutlook.com
- http://www.MSDNAA.Net
- http://www.csharphelp.com
- http://www.poetry.com/Publications/
display.asp?ID= P3966388&BN=999 &PN=2
- Or, just search on "J.V.Ravichandr an"
at http://www.Google.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #10

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

Similar topics

1
1832
by: bidalah | last post by:
Hello, I am looking for basic info on installing and using MSDE. I am trying to install and play with MSDE on my PC (Win2000). I finally managed to work my way through installation, and named instances but I am finding no information on how to simply START the database engine and get to a sql prompt! I have manually started the MSSQL and SQLAGENT services, and tried running sqlservr.exe and osql.exe (just guessing) without success. ...
18
2132
by: steve | last post by:
I'm trying to create a structure of three pointers to doubles. For which I have: typedef struct { double *lst_t, *lst_vc, *lst_ic; } last_values; I then need to allocate space for last_values as well as assign the value of a pointer to the assigned space. Which I think I'm doing by using:
3
1201
by: Keith Rebello | last post by:
I have an object called ColumnSection which represents a reinforced concrete column. This object contains an arraylist called Diagrams which contains Graph2D objects which are essentially X-Y plots. The Graph2D object has 2 public methods - Draw, which draws the plot on a bitmap in memory and DisplayGraph which blits the bitmap on to a Panel or PictureBox. I have a public ReadOnly property in the ColumnSection called...
1
7775
by: Ottavio | last post by:
Hello, I'm having some problems with the authentication during a web service call I know I have to add the "Authorization: Basic xxxxxxxx" in the http header (not soap header) but I can't find a way to add it. I've tryed to use ethereal to watch what I'm sending and I can see all the header (Accept-Language,Accept-Encoding,User-Agent,Host,Connection,..) and the SOAP xml message but there is no "Authorization: Basic ......" at all.
43
2404
by: Bill H | last post by:
25 years ago every computer came with some form of Basic interpreter so you could use yoru computer without having to buy more software. Is Javascript (teamed with HTML) set to become the new Basic, where anyone with a computer can start writing code without having to purchase any expensive languages? Bill H
0
9673
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9524
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10217
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10003
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9047
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7546
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5440
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4114
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.