473,651 Members | 2,742 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

String() declaration?

Can someone please explan the difference between

Dim temp as String()

and

Dim temp() as String

in terms of syntax and practical usage? I thought I knew, but of late have
become confused due to reasons too complicated to go in here.

Will appreciate your inputs.
--
Anil Gupte
www.keeninc.net
www.icinema.com
www.wizo.tv
Oct 29 '08 #1
16 2149
Anil Gupte/iCinema.com wrote:
Can someone please explan the difference between

Dim temp as String()

and

Dim temp() as String

in terms of syntax
The obvious: the location of the parentheses.
and practical usage?
None.

Andrew
Oct 29 '08 #2
Basically it means :

- temp is an array of strings

- the temp array is holding strings

So this is two ways to tell the same thing. I tend to favor #2 as it is more
consistent with waht you do in your code i.e. temp(myIndex).

--
Patrice

"Anil Gupte/iCinema.com" <an*******@icin ema.coma écrit dans le message de
groupe de discussion : uA************* *@TK2MSFTNGP05. phx.gbl...
Can someone please explan the difference between

Dim temp as String()

and

Dim temp() as String

in terms of syntax and practical usage? I thought I knew, but of late
have become confused due to reasons too complicated to go in here.

Will appreciate your inputs.
--
Anil Gupte
www.keeninc.net
www.icinema.com
www.wizo.tv
Oct 29 '08 #3
On Oct 29, 9:26*am, "Anil Gupte/iCinema.com" <anil-l...@icinema.co m>
wrote:
Can someone please explan the difference between

Dim temp as String()

and

Dim temp() as String

in terms of syntax and practical usage? *I thought I knew, but of late have
become confused due to reasons too complicated to go in here.

Will appreciate your inputs.
--
Anil Guptewww.keenin c.netwww.icinem a.comwww.wizo.t v
Fairly same. However you can get used to one of them depending on your
taste. Putting parantheses just after variable to declare array seems
more than the other decleration option on the net.

Thanks,

Onur G.
Oct 29 '08 #4
Onur,
>Fairly same.
Fairly? In my idea simple like Andrew wrote None
>However you can get used to one of them depending on your
taste. Putting parantheses just after variable to declare array seems
more than the other decleration option on the net.
What do you want to tell with the last sentence?
Beside that it is not true, this behaviour is a language feature not a Net
feature.

Because that a lot of Islamitic countries use the Arabic language, does not
mean that every Islamatic country should do that.

The later sentence jmo.

Cor

Oct 30 '08 #5
On Oct 30, 7:23*am, "Cor Ligthert[MVP]" <Notmyfirstn... @planet.nl>
wrote:
Onur,
Fairly same.

Fairly? In my idea simple like Andrew wrote None
I meant they are same, just location of parantheses are different,
that's all.
However you can get used to one of them depending on your
taste. Putting parantheses just after variable to declare array seems
more than the other decleration option on the net.

What do you want to tell with the last sentence?
Beside that it is not true, this behaviour is a language feature not a Net
feature.
I meant, you can use both and it depends on your taste, plus i did NOT
claim that is a .net feature, it's obvious that VB language allows 2
types of array declaration of strings.. And also i found more samples
that uses parantheses just after variable when declaring string
arrays.
Because that a lot of Islamitic countries use the Arabic language, does not
mean that every Islamatic country should do that.
Couldn't set up any relation between the topic and with that sentence
and i beleive it's not needed to extend issue with off-topic
statements.
The later sentence jmo.

Cor
Onur G.

Oct 30 '08 #6
Hello Anil ,

Dim temp() as String

is the classic VB syntax to declare an array

VB also supports

Dim temp as String()
This method is more intuitiv to programmers with a C background , this is
also a big advantage for coders who both use C# and VB
in early versions of VB.Net ( 2002 and i guess 2003 i believe , but i am not
sure ) there was a difference

Between the two the new method could not be used to declare and instantiate
the array in one line

Dim temp() as String ={"hello","worl d"} worked but Dim temp as
String()={"hell o","world"} did not work in early versions

Nowadays in VB.Net 2005 and 2008 both work the same so it becomes a mather
of taste wich one of the 2 you use
as you see the VB language also evolves in a forward kind of way :-)

I concur with Onur regarding his remark that you see more and more "Dim temp
as String()"in code examples on the net
HTH

Michel Posseth [MCP]
http://www.vbdotnetcoder.com


"Anil Gupte/iCinema.com" <an*******@icin ema.comschreef in bericht
news:uA******** ******@TK2MSFTN GP05.phx.gbl...
Can someone please explan the difference between

Dim temp as String()

and

Dim temp() as String

in terms of syntax and practical usage? I thought I knew, but of late
have become confused due to reasons too complicated to go in here.

Will appreciate your inputs.
--
Anil Gupte
www.keeninc.net
www.icinema.com
www.wizo.tv
Oct 30 '08 #7
Onur,

Couldn't set up any relation between the topic and with that sentence
and i beleive it's not needed to extend issue with off-topic
statements.

This of topic sentence is completely yours.

However, I don't agree that it is off topic to use examples related to
natural languages, you know this is a language newsgroup.

Cor
Oct 30 '08 #8
On Oct 30, 1:32*pm, "Cor Ligthert[MVP]" <notmyfirstn... @planet.nl>
wrote:
Onur,

Couldn't set up any relation between the topic and with that sentence
and i beleive it's not needed to extend issue with off-topic
statements.

This of topic sentence is completely yours.

However, I don't agree that it is off topic to use examples related to
natural languages, you know this is a language newsgroup.

Cor
I meant that off-topic statement which you posted:
"Because that a lot of Islamitic countries use the Arabic language,
does not
mean that every Islamatic country should do that. "

Seems you like making that kind of statements frequently as i came
across on that newsgroup, however it is not important, the thing which
i focused was the topic.(string arrays).

However thanks Michel for focusing on topic and explaining better what
i meant.

Onur G.

Oct 30 '08 #9
Cor Ligthert wrote:
<snip>
However you can get used to one of them depending on your
taste. Putting parantheses just after variable to declare array seems
more than the other decleration option on the net.

What do you want to tell with the last sentence?
Beside that it is not true, this behaviour is a language feature not a Net
feature.
<snip>

Maybe my english is too crippled (I'm Brazilian) but it seemed clear
in the original sentence that "net" in the phrase meant *the
Internet*, not Microsoft's .Net, in the sense that the poster sees *in
the Internet* more people using parenthesis in the variable name than
in the type name.

Regards,

Branco.
Oct 30 '08 #10

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

Similar topics

4
19899
by: Jeff Williams | last post by:
This doesn't compile: const char** ids = { "aaa", "bbb", "ccc" }; I hope the above illustrates what I am trying to do, if it is possible, what
12
16165
by: Riley DeWiley | last post by:
I am looking for a graceful way to declare a string const that is to be visible across many files. If I do this: //----hdr.h const char * sFoo = "foo"; //file.cpp
5
11729
by: MLH | last post by:
I'm working with lots of long strings now, it seems. I have to import them & parse them constantly. The A97 memo field type supports only 32768 chars. What happens when this is processed... Dim MyString As String Am I getting VLS declaration or a FLS declaration? Can I control which I get somehow? I have done some homework, but I don't understand
7
4352
by: al | last post by:
char s = "This string literal"; or char *s= "This string literal"; Both define a string literal. Both suppose to be read-only and not to be modified according to Standard. And both have type of "const char *". Right? But why does the compiler I am using allow s to be modified, instead of generating compile error?
4
5387
by: songkv | last post by:
Hi, I am trying to reassign an array of char to a string literal by calling a function. In the function I use pointer-to-pointer since I want to reassign the "string array pointer" to the string literal. But the second printf seems to give me garbage. Any advise on what I am doing wrong? Thanx
12
919
by: Terry | last post by:
If the string object contain like below: string Mystring = " "; What function should be used for checking the "Mystring" is no char inside? Thanks Terry
24
2694
by: v4vijayakumar | last post by:
why the following string, 'str' is read-only? char *str = "test string"; anyhow 'str' needs to be in memory. do you think, making 'str' red-only would gain performance? or, it is right?
31
3121
by: Peter Michaux | last post by:
Hi, I want to know the name of an object's constructor function as a string. Something like this <script type="text/javascript"> function Foo(){}; var a = new Foo(); alert('"' + a.constructor.toString().match(/function\s*(+)/)
5
2888
by: polas | last post by:
Good morning, I have a quick question to clear up some confusion in my mind. I understand that using a string literal in a declaration such as char *p = "string literal" declares a pointer to memory holding the string and the string might very well be held in read only memory. However, I am sure that I read somewhere that the declaration char a = "string literal", even though a is an array (and I understand the differences between...
4
3822
by: Chris Forone | last post by:
hello group, why have i to bracket the second ctor param in the following example? thx & hand, chris #include <fstream> #include <iterator> int main()
0
8803
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
8700
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...
1
8465
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8581
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
7298
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...
0
4144
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...
0
4285
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1910
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1588
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.