Home All Groups Group Topic Archive Search About

converting from basic to vb6

Author
12 Mar 2009 1:00 AM
Viper900
Hi
Can someone convert this code to vb6 Please

data 153, 150, 102 105,102,150,153,105
for a=1 to4:read var1(a):next
for a=1 to4:read var2(a):next
some code
for a = 1to 12
for b = 1 to 4
command, only accepts one argument, has to read 4 numbers from var1 or var2
some code
next a: next b

Thank you

Author
12 Mar 2009 1:34 AM
Larry Serflaten
"Viper900" <Viper***@discussions.microsoft.com> wrote
> Hi
> Can someone convert this code to vb6 Please
>
> data 153, 150, 102 105,102,150,153,105
> for a=1 to4:read var1(a):next
> for a=1 to4:read var2(a):next
> some code
> for a = 1to 12
> for b = 1 to 4
> command, only accepts one argument, has to read 4 numbers from var1 or var2
> some code
> next a: next b

No doubt you'll get differing replies, but one solution would be

var1 = Array(153,  150, 102, 105)
var2 = Array(102, 150, 153, 105)

Of course dimensioning the arrays and asigning data would be the more
prudent thing to do, but I leave that for you discover....

LFS
Author
12 Mar 2009 2:13 AM
Karl E. Peterson
Larry Serflaten wrote:
Show quoteHide quote
> "Viper900" <Viper***@discussions.microsoft.com> wrote
>> Hi
>> Can someone convert this code to vb6 Please
>>
>> data 153, 150, 102 105,102,150,153,105
>> for a=1 to4:read var1(a):next
>> for a=1 to4:read var2(a):next
>> some code
>> for a = 1to 12
>> for b = 1 to 4
>> command, only accepts one argument, has to read 4 numbers from var1 or var2
>> some code
>> next a: next b
>
> No doubt you'll get differing replies, but one solution would be
>
> var1 = Array(153,  150, 102, 105)
> var2 = Array(102, 150, 153, 105)
>
> Of course dimensioning the arrays and asigning data would be the more
> prudent thing to do, but I leave that for you discover....

Wonder what his teacher advised? ;-)
--
..NET: It's About Trust!
http://vfred.mvps.org
Author
12 Mar 2009 3:49 PM
Rick Rothstein
Show quote Hide quote
>>> Can someone convert this code to vb6 Please
>>>
>>> data 153, 150, 102 105,102,150,153,105
>>> for a=1 to4:read var1(a):next
>>> for a=1 to4:read var2(a):next
>>> some code
>>> for a = 1to 12
>>> for b = 1 to 4
>>> command, only accepts one argument, has to read 4 numbers from var1 or
>>> var2
>>> some code
>>> next a: next b
>>
>> No doubt you'll get differing replies, but one solution would be
>>
>> var1 = Array(153,  150, 102, 105)
>> var2 = Array(102, 150, 153, 105)
>>
>> Of course dimensioning the arrays and asigning data would be the more
>> prudent thing to do, but I leave that for you discover....
>
> Wonder what his teacher advised? ;-)

Do you really think anyone is teaching programming using one of the
interpreted DOS based BASICs as a basis? That seems very unlikely to me.
Hell, except for "old timers" like us, I wonder how many programmers of
today have ever worked with an interpreted DOS based BASIC, let alone know
the functions and statements that were unique to them (such as DATA, READ,
INKEY, etc.).

--
Rick (MVP - Excel)
Author
12 Mar 2009 6:54 PM
Karl E. Peterson
Rick Rothstein wrote:
Show quoteHide quote
>>>> Can someone convert this code to vb6 Please
>>>>
>>>> data 153, 150, 102 105,102,150,153,105
>>>> for a=1 to4:read var1(a):next
>>>> for a=1 to4:read var2(a):next
>>>> some code
>>>> for a = 1to 12
>>>> for b = 1 to 4
>>>> command, only accepts one argument, has to read 4 numbers from var1 or
>>>> var2
>>>> some code
>>>> next a: next b
>>>
>>> No doubt you'll get differing replies, but one solution would be
>>>
>>> var1 = Array(153,  150, 102, 105)
>>> var2 = Array(102, 150, 153, 105)
>>>
>>> Of course dimensioning the arrays and asigning data would be the more
>>> prudent thing to do, but I leave that for you discover....
>>
>> Wonder what his teacher advised? ;-)
>
> Do you really think anyone is teaching programming using one of the
> interpreted DOS based BASICs as a basis? That seems very unlikely to me.
> Hell, except for "old timers" like us, I wonder how many programmers of
> today have ever worked with an interpreted DOS based BASIC, let alone know
> the functions and statements that were unique to them (such as DATA, READ,
> INKEY, etc.).

I was really wondering what spurred the post.  The bits within the nested For loops
seemed like instructor code for "fill in the blank", but I could sure be wrong.
Sort of an archeological exercise, maybe? <g>  I dunno...
--
..NET: It's About Trust!
http://vfred.mvps.org
Author
12 Mar 2009 4:10 PM
Henning
Show quote Hide quote
"Viper900" <Viper***@discussions.microsoft.com> skrev i meddelandet
news:8C360A16-D154-4FBC-AC70-50F5F97E5D67@microsoft.com...
> Hi
> Can someone convert this code to vb6 Please
>
> data 153, 150, 102 105,102,150,153,105
> for a=1 to4:read var1(a):next
> for a=1 to4:read var2(a):next
> some code
> for a = 1to 12
> for b = 1 to 4
> command, only accepts one argument, has to read 4 numbers from var1 or
> var2
> some code
> next a: next b
>
> Thank you

And just to get i compiling, swap Next a: Next b.

/Henning
Author
12 Mar 2009 6:55 PM
Karl E. Peterson
Henning wrote:
Show quoteHide quote
> "Viper900" <Viper***@discussions.microsoft.com> skrev i meddelandet
> news:8C360A16-D154-4FBC-AC70-50F5F97E5D67@microsoft.com...
>> Hi
>> Can someone convert this code to vb6 Please
>>
>> data 153, 150, 102 105,102,150,153,105
>> for a=1 to4:read var1(a):next
>> for a=1 to4:read var2(a):next
>> some code
>> for a = 1to 12
>> for b = 1 to 4
>> command, only accepts one argument, has to read 4 numbers from var1 or
>> var2
>> some code
>> next a: next b
>>
>> Thank you
>
> And just to get i compiling, swap Next a: Next b.

Swap was deprecated in VB. <gd&r>
--
..NET: It's About Trust!
http://vfred.mvps.org
Author
12 Mar 2009 7:38 PM
Henning
Show quote Hide quote
"Karl E. Peterson" <k***@mvps.org> skrev i meddelandet
news:ex3dYQ0oJHA.1288@TK2MSFTNGP02.phx.gbl...
> Henning wrote:
>> "Viper900" <Viper***@discussions.microsoft.com> skrev i meddelandet
>> news:8C360A16-D154-4FBC-AC70-50F5F97E5D67@microsoft.com...
>>> Hi
>>> Can someone convert this code to vb6 Please
>>>
>>> data 153, 150, 102 105,102,150,153,105
>>> for a=1 to4:read var1(a):next
>>> for a=1 to4:read var2(a):next
>>> some code
>>> for a = 1to 12
>>> for b = 1 to 4
>>> command, only accepts one argument, has to read 4 numbers from var1 or
>>> var2
>>> some code
>>> next a: next b
>>>
>>> Thank you
>>
>> And just to get i compiling, swap Next a: Next b.
>
> Swap was deprecated in VB. <gd&r>
> --
> .NET: It's About Trust!
> http://vfred.mvps.org
>

Yeah, and
Sub Swap(ByRef nxta As Byte, ByRef nxtb As Byte)
    Dim tmp As Byte
    tmp = nxta
    nxta = nxtb
    nxtb = tmp
End Sub
will not be of any help either... :))

/Henning
Author
12 Mar 2009 7:57 PM
Rick Rothstein
Show quote Hide quote
>> Swap was deprecated in VB. <gd&r>
>> --
>> .NET: It's About Trust!
>> http://vfred.mvps.org
>>
>
> Yeah, and
> Sub Swap(ByRef nxta As Byte, ByRef nxtb As Byte)
>    Dim tmp As Byte
>    tmp = nxta
>    nxta = nxtb
>    nxtb = tmp
> End Sub
> will not be of any help either... :))

Why not eliminate creating the 'tmp' variable?

Sub Swap(ByRef nxta As Byte, ByRef nxtb As Byte)
  nxta = nxta Xor nxtb
  nxtb = nxta Xor nxtb
  nxta = nxta Xor nxtb
End Sub

--
Rick (MVP - Excel)
Author
12 Mar 2009 9:10 PM
Henning
Show quote Hide quote
"Rick Rothstein" <rick.newsNO.SPAM@NO.SPAMverizon.net> skrev i meddelandet
news:%23DLEFz0oJHA.4448@TK2MSFTNGP05.phx.gbl...
>>> Swap was deprecated in VB. <gd&r>
>>> --
>>> .NET: It's About Trust!
>>> http://vfred.mvps.org
>>>
>>
>> Yeah, and
>> Sub Swap(ByRef nxta As Byte, ByRef nxtb As Byte)
>>    Dim tmp As Byte
>>    tmp = nxta
>>    nxta = nxtb
>>    nxtb = tmp
>> End Sub
>> will not be of any help either... :))
>
> Why not eliminate creating the 'tmp' variable?
>
> Sub Swap(ByRef nxta As Byte, ByRef nxtb As Byte)
>  nxta = nxta Xor nxtb
>  nxtb = nxta Xor nxtb
>  nxta = nxta Xor nxtb
> End Sub
>
> --
> Rick (MVP - Excel)
>

Too many lines of code from U, just eliminating 1 line. ;)

/Henning