From: Cor Ligthert[MVP] on
But explaining why the original code would not run would've been more
helpful. It would go like this in VB6. I was perplex from your reply.
So I made the most easy code, it could also have been.

Dim b() As String
Dim a As String
a = "Hello World"
a = Replace(a, " ", " ")
b = Split(a, " ").

But from some like you seems to be more focused on nitpicking in this
newsgroup then to try be real helpful with replies.

It is in fact not a VB problem, but because of that Nxt has two methods
Split and Replace in what is called in Nxt namespaces.

However, that it is not a VB problem does not change that it will not
compile (build) in later versions of VB, without adding that strings.

Cor

"Mike Williams" <Mike(a)WhiskyAndCoke.com> wrote in message
news:eOYQ7AhyKHA.404(a)TK2MSFTNGP02.phx.gbl...
>
> "Michel Posseth [MCP]" <msdn(a)posseth.com> wrote in message
> news:FDB5A490-AC89-487C-98CA-A883FEBC0B7F(a)microsoft.com...
>
>>>> [Cor Ligthert said]
>>>> Dim b
>>>> Dim a
>>>> a = "Hello World"
>>>> You mean this wont not compile in any way in VB6?
>>
>>> [Saga said] Technically, it will compile in VB6, but the
>>> above is not the best approach to . . .
>>
>> [Michel Posseth said] No Mike is right it wouldn`t even compile
>> unless if you have Option explicit OFF and the "require variable
>> declarion setting"switched to the OFF position in the General tab
>> of the options dialogbox otherwise VB6 wil enforce a type
>> declaration , and wich self respecting professional coder whould
>> code with these settings ? ;-)
>
> You're wrong there, Michel, and I think you've got hold of the wrong end
> of the stick as well. I never said that the above code would not compile.
> In fact if you read carefully what I actually posted in response to the
> message which contained that code you will see that I said it /would/
> compile, but that it was /not/ the code Cor Ligthert had originally posted
> when I had previously said it would not.
>
> Cor was trying to cover his tracks by querying a statement of mine, which
> was perfectly true, by changing his previously posted code and by
> dishonestly pretending to paraphrase it when he repeated his question,
> hoping that it would not be noticed. So Saga is quite right in saying that
> Cor Ligthert's latest attempt (as shown above) would compile, and he is of
> course also quite right in saying that it is not the best approach (for
> the various reasons he quoted, including the fact that it would default to
> the Variant data type).
>
> Contrary to what you have stated, Michel, VB does /not/ enforce a type
> declaration in such cases, regardless of whether you are using Option
> Explicit or not and regardless of the setting of the "Require Variable
> Declaration" check box in the Options dialog. Option Explicit forces you
> to declare a variable, but it does not force you to declare its type. All
> that will happen if you fail to declare its type is that VB will cause the
> type to default to a Variant. So, Both Saga and myself were correct in
> saying that Cor Ligthert's latest attempt would actually compile (although
> his previous attempts would not).
>
> Mike
>
>
From: Tom Shelton on
On 2010-03-23, Cor Ligthert[MVP] <Notmyfirstname(a)planet.nl> wrote:
> But explaining why the original code would not run would've been more
> helpful. It would go like this in VB6. I was perplex from your reply.
> So I made the most easy code, it could also have been.
>
> Dim b() As String
> Dim a As String
> a = "Hello World"
> a = Replace(a, " ", " ")
> b = Split(a, " ")
>
> But from some like you seems to be more focused on nitpicking in this
> newsgroup then to try be real helpful with replies.
>
> It is in fact not a VB problem, but because of that Nxt has two methods
> Split and Replace in what is called in Nxt namespaces.
>
> However, that it is not a VB problem does not change that it will not
> compile (build) in later versions of VB, without adding that strings.

You don't have to qualify Replace and Split in VB.NET.... The above
compiles just fine in either classic or .net.

--
Tom Shelton
From: Cor Ligthert[MVP] on
Tom,

You are right; somehow I started doing it with a qualification, I don't know
why anymore.

Although I (almost) never use it (beside samples) like this in newer
versions than VB6

Thanks for pointing me on that.

Cor

"Tom Shelton" <tom_shelton(a)comcastXXXXXXX.net> wrote in message
news:OraikhoyKHA.5360(a)TK2MSFTNGP06.phx.gbl...
> On 2010-03-23, Cor Ligthert[MVP] <Notmyfirstname(a)planet.nl> wrote:
>> But explaining why the original code would not run would've been more
>> helpful. It would go like this in VB6. I was perplex from your reply.
>> So I made the most easy code, it could also have been.
>>
>> Dim b() As String
>> Dim a As String
>> a = "Hello World"
>> a = Replace(a, " ", " ")
>> b = Split(a, " ")
>>
>> But from some like you seems to be more focused on nitpicking in this
>> newsgroup then to try be real helpful with replies.
>>
>> It is in fact not a VB problem, but because of that Nxt has two methods
>> Split and Replace in what is called in Nxt namespaces.
>>
>> However, that it is not a VB problem does not change that it will not
>> compile (build) in later versions of VB, without adding that strings.
>
> You don't have to qualify Replace and Split in VB.NET.... The above
> compiles just fine in either classic or .net.
>
> --
> Tom Shelton

From: Saga on
We are talking about the following code?

Dim b
Dim a
a = "Hello World"
a = Replace(a, " ", " ")
b = Split(a, " ")

What does option explicit have to do with the above snippet?

Two variables are used, a and b and both are declared using Dim.

Agreed, it is baaaad to turn off Option Explicit, but I have it on
and just entered the above snippet and it compiled fine. Logically
I still find fault withi, but compile it does. VB6 dev. environment
*is* assumed. Thanks for your feedback! Saga

"Michel Posseth [MCP]" <msdn(a)posseth.com> wrote in message
news:FDB5A490-AC89-487C-98CA-A883FEBC0B7F(a)microsoft.com...
> No Mike is right it wouldn`t even compile unless if you have Option
> explicit OFF and the
> "require variable declarion setting"switched to the OFF position in the
> General tab of the options dialogbox
> otherwise VB6 wil enforce a type declaration , and wich self respecting
> professional coder whould code with these settings ? ;-)
>
> So if it compiles on your side you might investigate the above settings
> and recompile some of your projects just to be sure ....
>
> HTH
>
> Michel
>
>
>
> "Saga" <antiSpam(a)nowhere.com> schreef in bericht
> news:OLVw%23QdyKHA.5040(a)TK2MSFTNGP02.phx.gbl...
>>
>> "Cor Ligthert[MVP]" <Notmyfirstname(a)planet.nl> wrote in message
>> news:eVaUpNSyKHA.3536(a)TK2MSFTNGP06.phx.gbl...
>>>
>>> Dim b Dim a a = "Hello World"
>>> a = Replace(a, " ", " ")
>>> b = Split(a, " ")
>>>
>>> You mean this wont not compile in any way in VB6?
>>>
>> Technically, it will compile in VB6, but the above is not the best
>> approach to
>> the problem. As they say, not everything that glitters is gold and not
>> everything
>> that compiles is good code:
>>
>> a. Dim - why use a variant? both declarations are better off being
>> defined
>> as strings.
>> b. For readability, Dim b should be dim b() ... This tells the code
>> reader early
>> on that it will be used as an array.
>> c. a = Replace(a, " ", " "). This is ok if and only if the string has 2
>> continous
>> spaces, but will fail if there are more than 2 contiguous spaces in
>> the string.
>> You need some sortof loop to accomplish this objetive thoroughly.
>>
>> Granted, these are trivial issues, but to some one that is begniing in
>> this language
>> it can be misleading.
>>
>> Since you mention that you do not have VB6 installed (not sure if not
>> installed
>> at all or just in the PC where you were when you posted this) I would
>> definitely
>> recommend that you install this development system and test any solutions
>> that you post. Regards, Saga
>>
>>
>>
>


From: Saga on
Hi Cor, I did not mean to nitpick - that was not my intention. It
is important to understand that many that come here are beginners
and most likely will not know the difference between inadvertently
declaring a variant and declaring a string and the optimization issues
of these two data types. This is why we should test the code before
we (and I *really* include myself here) post and also make a best
effort to post good code so that bad programming habits are not
picked up by the newcomers to this (or any other) language. This
is in contrast to examples provided by MS itself where certain
"really-bad" VB statements are used. Regards, Saga


"Cor Ligthert[MVP]" <Notmyfirstname(a)planet.nl> wrote in message
news:OmlDWJmyKHA.4156(a)TK2MSFTNGP06.phx.gbl...
> But explaining why the original code would not run would've been more
> helpful. It would go like this in VB6. I was perplex from your reply.
> So I made the most easy code, it could also have been.
>
> Dim b() As String
> Dim a As String
> a = "Hello World"
> a = Replace(a, " ", " ")
> b = Split(a, " ").
>
> But from some like you seems to be more focused on nitpicking in this
> newsgroup then to try be real helpful with replies.
>
> It is in fact not a VB problem, but because of that Nxt has two methods
> Split and Replace in what is called in Nxt namespaces.
>
> However, that it is not a VB problem does not change that it will not
> compile (build) in later versions of VB, without adding that strings.
>
> Cor
>
> "Mike Williams" <Mike(a)WhiskyAndCoke.com> wrote in message
> news:eOYQ7AhyKHA.404(a)TK2MSFTNGP02.phx.gbl...
>>
>> "Michel Posseth [MCP]" <msdn(a)posseth.com> wrote in message
>> news:FDB5A490-AC89-487C-98CA-A883FEBC0B7F(a)microsoft.com...
>>
>>>>> [Cor Ligthert said]
>>>>> Dim b
>>>>> Dim a
>>>>> a = "Hello World"
>>>>> You mean this wont not compile in any way in VB6?
>>>
>>>> [Saga said] Technically, it will compile in VB6, but the
>>>> above is not the best approach to . . .
>>>
>>> [Michel Posseth said] No Mike is right it wouldn`t even compile
>>> unless if you have Option explicit OFF and the "require variable
>>> declarion setting"switched to the OFF position in the General tab
>>> of the options dialogbox otherwise VB6 wil enforce a type
>>> declaration , and wich self respecting professional coder whould
>>> code with these settings ? ;-)
>>
>> You're wrong there, Michel, and I think you've got hold of the wrong end
>> of the stick as well. I never said that the above code would not compile.
>> In fact if you read carefully what I actually posted in response to the
>> message which contained that code you will see that I said it /would/
>> compile, but that it was /not/ the code Cor Ligthert had originally
>> posted when I had previously said it would not.
>>
>> Cor was trying to cover his tracks by querying a statement of mine, which
>> was perfectly true, by changing his previously posted code and by
>> dishonestly pretending to paraphrase it when he repeated his question,
>> hoping that it would not be noticed. So Saga is quite right in saying
>> that Cor Ligthert's latest attempt (as shown above) would compile, and he
>> is of course also quite right in saying that it is not the best approach
>> (for the various reasons he quoted, including the fact that it would
>> default to the Variant data type).
>>
>> Contrary to what you have stated, Michel, VB does /not/ enforce a type
>> declaration in such cases, regardless of whether you are using Option
>> Explicit or not and regardless of the setting of the "Require Variable
>> Declaration" check box in the Options dialog. Option Explicit forces you
>> to declare a variable, but it does not force you to declare its type. All
>> that will happen if you fail to declare its type is that VB will cause
>> the type to default to a Variant. So, Both Saga and myself were correct
>> in saying that Cor Ligthert's latest attempt would actually compile
>> (although his previous attempts would not).
>>
>> Mike
>>
>>


First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5 6 7 8 9
Prev: Combobox Showing Right Justified
Next: Can't make exe