473,804 Members | 3,081 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
12 1278
> Dim strMyData as string() is simply wrong syntax. is simply wrong syntax.

Don't be so sure. I still think it is just depracted syntax.

Try this:

Dim s as string
Intellisense says for s = "Dim s as string"

Dim s() as string
Intellisense says for s = "Dim s() as string"

Dim s as string()
Intellisense says for s = "Dim s() as string"

Also this will compile:
Dim s as string()
Redim s(10)

And this won't:
Dim s a string
Redim s(10)

Greg

"Ravichandr an J.V." <jv************ @yahoo.com> wrote in message
news:O$******** ******@TK2MSFTN GP15.phx.gbl...
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 #11
Greg,

"Greg Burns" <greg_burns@DON T_SPAM_ME_hotma il.com> schrieb_
Dim strMyData as string() is simply wrong syntax. is simply wrong syntax.


Don't be so sure. I still think it is just depracted syntax.


I don't think it's deprecated. It's only an alternative that works and that
will work for forseeable future. VB6 only supported the 'Dim X() As Y'
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 #12

"Ravichandr an J.V." <jv************ @yahoo.com> wrote
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 might want to inform MSFT that syntax is wrong since they
use that syntax in the documentation to explain creating an array!

(See 'New keyword' in VB.Net help)

There is no parameterless constructor for the String class:

strMyData = New String()

That syntax is wrong, which indicates that there is no 'default constructor'
for the String class.

Following primative types with parentheses is another valid data type as
evidensed by:

Dim a As String() = {"X", "Y"}
Dim b As Integer() = {1, 2}

The parentheses indicate the Array class is used to build a strongly typed
array. (Note the array class also has no 'default constructor' and the
desired type is a requirement of the shared CreateInstance method.)

HTH
LFS

Nov 21 '05 #13

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
2134
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
2409
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
9591
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
10594
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10343
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
9166
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
7631
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
6861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4306
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
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3001
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.