For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic > December 2005 > Dim a byte array.









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Dim a byte array.
Boki

2005-12-11, 9:55 pm

Hi All,
Could you please advice how to convert this code to VB6? Thank
you very much!

private final short[] Reg ={ 0x01, 0x02, 0x03, 0x04 };

Best regards,
Boki.



Randy Birch

2005-12-12, 3:55 am

dim b(0 to 3) as byte

b(0) = &H1
b(1) = &H2
b(2) = &H3
b(3) = &H4



--

Randy Birch
MS MVP Visual Basic
http://vbnet.mvps.org/
----------------------------------------------------------------------------
Read. Decide. Sign the petition to Microsoft.
http://classicvb.org/petition/
----------------------------------------------------------------------------



"Boki" <bokiteam@ms21.hinet.net> wrote in message
news:OevaOds$FHA.2784@tk2msftngp13.phx.gbl...
: Hi All,
: Could you please advice how to convert this code to VB6? Thank
: you very much!
:
: private final short[] Reg ={ 0x01, 0x02, 0x03, 0x04 };
:
: Best regards,
: Boki.
:
:
:

Boki

2005-12-12, 3:55 am

Can I write them in a single line ?

or

Could you please advice the read/data method?

ex:

Data 1,2,3,4,5

but how to read them back ?

Best regards,
Boki.


"Randy Birch" <rgb_removethis@mvps.org>
???????:u%234wt%23s$FHA.328@TK2MSFTNGP14.phx.gbl...
> dim b(0 to 3) as byte
>
> b(0) = &H1
> b(1) = &H2
> b(2) = &H3
> b(3) = &H4
>
>
>
> --
>
> Randy Birch
> MS MVP Visual Basic
> http://vbnet.mvps.org/
> ----------------------------------------------------------------------------
> Read. Decide. Sign the petition to Microsoft.
> http://classicvb.org/petition/
> ----------------------------------------------------------------------------
>
>
>
> "Boki" <bokiteam@ms21.hinet.net> wrote in message
> news:OevaOds$FHA.2784@tk2msftngp13.phx.gbl...
> : Hi All,
> : Could you please advice how to convert this code to VB6?
> Thank
> : you very much!
> :
> : private final short[] Reg ={ 0x01, 0x02, 0x03, 0x04 };
> :
> : Best regards,
> : Boki.
> :
> :
> :
>



Randy Birch

2005-12-12, 3:55 am

: Can I write them in a single line ?


No.


: Could you please advice the read/data method?

The old Basic Data/Read method is not supported in modern versions of basic.
If the data was in a file as byte data you could read using the Binary file
access method, but only the variant data type provides for a one-line array
method, e.g.

dim x() as variant

x()=array(&H1,&H2,&H3,&H4)

.... but the result would be an array of variants of type Long, not of type
Byte.


--

Randy Birch
MS MVP Visual Basic
http://vbnet.mvps.org/
----------------------------------------------------------------------------
Read. Decide. Sign the petition to Microsoft.
http://classicvb.org/petition/
----------------------------------------------------------------------------



"Boki" <bokiteam@ms21.hinet.net> wrote in message
news:%23jfHLNt$FHA.504@TK2MSFTNGP12.phx.gbl...
: Can I write them in a single line ?
:
: or
:
: Could you please advice the read/data method?
:
: ex:
:
: Data 1,2,3,4,5
:
: but how to read them back ?
:
: Best regards,
: Boki.
:
:
: "Randy Birch" <rgb_removethis@mvps.org>
: ???????:u%234wt%23s$FHA.328@TK2MSFTNGP14.phx.gbl...
: > dim b(0 to 3) as byte
: >
: > b(0) = &H1
: > b(1) = &H2
: > b(2) = &H3
: > b(3) = &H4
: >
: >
: >
: > --
: >
: > Randy Birch
: > MS MVP Visual Basic
: > http://vbnet.mvps.org/
:
> ----------------------------------------------------------------------------

: > Read. Decide. Sign the petition to Microsoft.
: > http://classicvb.org/petition/
:
> ----------------------------------------------------------------------------

: >
: >
: >
: > "Boki" <bokiteam@ms21.hinet.net> wrote in message
: > news:OevaOds$FHA.2784@tk2msftngp13.phx.gbl...
: > : Hi All,
: > : Could you please advice how to convert this code to VB6?
: > Thank
: > : you very much!
: > :
: > : private final short[] Reg ={ 0x01, 0x02, 0x03, 0x04 };
: > :
: > : Best regards,
: > : Boki.
: > :
: > :
: > :
: >
:
:

Rick Rothstein [MVP - Visual Basic]

2005-12-12, 3:55 am

> : Can I write them in a single line ?
>
>
> No.


Does the Dim statement count as a line? I'm pretty sure this works...

Dim b() As Byte
b = StrConv(Chr$(&H1) & Chr$(&H2) & Chr$(&H3) & _
Chr$(&H4), vbFromUnicode)

Rick


Michael C

2005-12-12, 3:55 am

"Rick Rothstein [MVP - Visual Basic]" <rickNOSPAMnews@NOSPAMcomcast.net>
wrote in message
> Does the Dim statement count as a line? I'm pretty sure this works...
>
> Dim b() As Byte
> b = StrConv(Chr$(&H1) & Chr$(&H2) & Chr$(&H3) & _
> Chr$(&H4), vbFromUnicode)


VB syntax is so much simpler than C ;-)

Michael.


Boki

2005-12-12, 3:55 am

I got it, thanks a lot.

I am considering how to convert a java code to VB6 as less steps as
possible. : )

Best regards,
Boki.



"Rick Rothstein [MVP - Visual Basic]" <rickNOSPAMnews@NOSPAMcomcast.net> 撰寫於郵件新聞:utH1tat$FHA.3096@TK2MSFTNGP14.phx.gbl...
>
> Does the Dim statement count as a line? I'm pretty sure this works...
>
> Dim b() As Byte
> b = StrConv(Chr$(&H1) & Chr$(&H2) & Chr$(&H3) & _
> Chr$(&H4), vbFromUnicode)
>
> Rick
>
>



Boki

2005-12-12, 3:55 am

So, could you please advice, can we convert variant to byte ? :)

Best regards,
Boki.

"Randy Birch" <rgb_removethis@mvps.org>
???????:O8BAMSt$FHA.1312@TK2MSFTNGP09.phx.gbl...
>: Can I write them in a single line ?
>
>
> No.
>
>
> : Could you please advice the read/data method?
>
> The old Basic Data/Read method is not supported in modern versions of
> basic.
> If the data was in a file as byte data you could read using the Binary
> file
> access method, but only the variant data type provides for a one-line
> array
> method, e.g.
>
> dim x() as variant
>
> x()=array(&H1,&H2,&H3,&H4)
>
> ... but the result would be an array of variants of type Long, not of type
> Byte.
>
>
> --
>
> Randy Birch
> MS MVP Visual Basic
> http://vbnet.mvps.org/
> ----------------------------------------------------------------------------
> Read. Decide. Sign the petition to Microsoft.
> http://classicvb.org/petition/
> ----------------------------------------------------------------------------
>
>
>
> "Boki" <bokiteam@ms21.hinet.net> wrote in message
> news:%23jfHLNt$FHA.504@TK2MSFTNGP12.phx.gbl...
> : Can I write them in a single line ?
> :
> : or
> :
> : Could you please advice the read/data method?
> :
> : ex:
> :
> : Data 1,2,3,4,5
> :
> : but how to read them back ?
> :
> : Best regards,
> : Boki.
> :
> :
> : "Randy Birch" <rgb_removethis@mvps.org>
> : ???????:u%234wt%23s$FHA.328@TK2MSFTNGP14.phx.gbl...
> : > dim b(0 to 3) as byte
> : >
> : > b(0) = &H1
> : > b(1) = &H2
> : > b(2) = &H3
> : > b(3) = &H4
> : >
> : >
> : >
> : > --
> : >
> : > Randy Birch
> : > MS MVP Visual Basic
> : > http://vbnet.mvps.org/
> :
> : > Read. Decide. Sign the petition to Microsoft.
> : > http://classicvb.org/petition/
> :
> : >
> : >
> : >
> : > "Boki" <bokiteam@ms21.hinet.net> wrote in message
> : > news:OevaOds$FHA.2784@tk2msftngp13.phx.gbl...
> : > : Hi All,
> : > : Could you please advice how to convert this code to VB6?
> : > Thank
> : > : you very much!
> : > :
> : > : private final short[] Reg ={ 0x01, 0x02, 0x03, 0x04 };
> : > :
> : > : Best regards,
> : > : Boki.
> : > :
> : > :
> : > :
> : >
> :
> :
>



Randy Birch

2005-12-12, 3:55 am

wow ... that's taking the long route, eh? <g>

--

Randy Birch
MS MVP Visual Basic
http://vbnet.mvps.org/
----------------------------------------------------------------------------
Read. Decide. Sign the petition to Microsoft.
http://classicvb.org/petition/
----------------------------------------------------------------------------



"Michael C" <mculley@NOSPAMoptushome.com.au> wrote in message
news:uHbFzwt$FHA.3928@tk2msftngp13.phx.gbl...
: "Rick Rothstein [MVP - Visual Basic]" <rickNOSPAMnews@NOSPAMcomcast.net>
: wrote in message
: > Does the Dim statement count as a line? I'm pretty sure this works...
: >
: > Dim b() As Byte
: > b = StrConv(Chr$(&H1) & Chr$(&H2) & Chr$(&H3) & _
: > Chr$(&H4), vbFromUnicode)
:
: VB syntax is so much simpler than C ;-)
:
: Michael.
:
:

Rick Rothstein [MVP - Visual Basic]

2005-12-12, 3:55 am

> > : Can I write them in a single line ?
>
> Does the Dim statement count as a line? I'm pretty sure this works...
>
> Dim b() As Byte
> b = StrConv(Chr$(&H1) & Chr$(&H2) & Chr$(&H3) & _
> Chr$(&H4), vbFromUnicode)


By the way, if you are willing to do a little pre-string manipulation, this
can be simplified a little bit...

In the Immediate Window, execute this code

? Chr$(&H1) & Chr$(&H2) & Chr$(&H3) & Chr$(&H4)

That will print out four "unprintable" characters which VB will represent by
showing 4 small boxes next to each other. These four boxes are a proper
string consisting of the characters with ASCII values of 1, 2, 3 and 4.
Simply Copy them into the Clipboard and then Paste them into the assignment
line I posted earlier in place of the concatenated Chr$ function calls. This
will produce this code...

Dim b() As Byte
b = StrConv("", vbFromUnicode)

I'm not sure if the ASCII values inside of the quotes will survive the
posting process or not, but you can try copying the code above and see. In
any case, String constants consisting of unprintable characters can be
produced in the manner I described above.

Rick


Randy Birch

2005-12-12, 3:55 am

amazingly it did survive ... it printed 1 2 3 4 to debug.

Private Sub Form_Load()

Dim b() As Byte

b = StrConv("", vbFromUnicode)
For cnt = 0 To 3
Debug.Print b(cnt)
Next

End Sub

> 1

2
3
4


--

Randy Birch
MS MVP Visual Basic
http://vbnet.mvps.org/
----------------------------------------------------------------------------
Read. Decide. Sign the petition to Microsoft.
http://classicvb.org/petition/
----------------------------------------------------------------------------



"Rick Rothstein [MVP - Visual Basic]" <rickNOSPAMnews@NOSPAMcomcast.net>
wrote in message news:%23GF12Ju$FHA.3944@TK2MSFTNGP10.phx.gbl...
:> > : Can I write them in a single line ?
: > >
: > > No.
: >
: > Does the Dim statement count as a line? I'm pretty sure this works...
: >
: > Dim b() As Byte
: > b = StrConv(Chr$(&H1) & Chr$(&H2) & Chr$(&H3) & _
: > Chr$(&H4), vbFromUnicode)
:
: By the way, if you are willing to do a little pre-string manipulation,
this
: can be simplified a little bit...
:
: In the Immediate Window, execute this code
:
: ? Chr$(&H1) & Chr$(&H2) & Chr$(&H3) & Chr$(&H4)
:
: That will print out four "unprintable" characters which VB will represent
by
: showing 4 small boxes next to each other. These four boxes are a proper
: string consisting of the characters with ASCII values of 1, 2, 3 and 4.
: Simply Copy them into the Clipboard and then Paste them into the
assignment
: line I posted earlier in place of the concatenated Chr$ function calls.
This
: will produce this code...
:
: Dim b() As Byte
: b = StrConv("", vbFromUnicode)
:
: I'm not sure if the ASCII values inside of the quotes will survive the
: posting process or not, but you can try copying the code above and see. In
: any case, String constants consisting of unprintable characters can be
: produced in the manner I described above.
:
: Rick
:
:

Rick Rothstein [MVP - Visual Basic]

2005-12-12, 3:55 am

> > > : Can I write them in a single line ?
>
> By the way, if you are willing to do a little pre-string manipulation,

this
> can be simplified a little bit...
>
> In the Immediate Window, execute this code
>
> ? Chr$(&H1) & Chr$(&H2) & Chr$(&H3) & Chr$(&H4)
>
> That will print out four "unprintable" characters which VB will represent

by
> showing 4 small boxes next to each other. These four boxes are a proper
> string consisting of the characters with ASCII values of 1, 2, 3 and 4.
> Simply Copy them into the Clipboard and then Paste them into the

assignment
> line I posted earlier in place of the concatenated Chr$ function calls.

This
> will produce this code...
>
> Dim b() As Byte
> b = StrConv("", vbFromUnicode)


Of course, it now dawns on me that this procedure can't work for the entire
set of characters with ASCII values less than decimal 32. The characters
corresponding to ASCII 9 (Tab) and ASCII 10 (Line Feed) are two characters
that won't "print" out boxes that can be copied... the Tab character will be
converted to blank spaces in the IDE and the Line Feed will physically move
the text after it to the next line.

Rick


Bob Butler

2005-12-12, 7:56 am

"Randy Birch" <rgb_removethis@mvps.org> wrote in message
news:u%234wt%23s$FHA.328@TK2MSFTNGP14.phx.gbl
> dim b(0 to 3) as byte

[color=darkred]

'short' is 'Integer' in VB isn't it? Or is the original source not C++?

--
Reply to the group so all can participate
VB.Net: "Fool me once..."

Schmidt

2005-12-12, 6:56 pm


"Randy Birch" <rgb_removethis@mvps.org> schrieb im Newsbeitrag
news:O8BAMSt$FHA.1312@TK2MSFTNGP09.phx.gbl...

> dim x() as variant
>
> x()=array(&H1,&H2,&H3,&H4)
>
> ... but the result would be an array of variants of type Long,
> not of type Byte.


TypeName(x(0)) would result with 'Integer' not 'Long' in this case (implicit
Autocasting below 5 Hex-Digits gives Integer).

Regarding the problem:
I would put a simple function into a Basic-Module:

Function InitByteArray(strByteValues As String) As Byte()
Dim i As Long, SArr() As String, B() As Byte
SArr = Split(strByteValues, ",")
If UBound(SArr) < 0 Then Exit Function
ReDim B(UBound(SArr))
For i = 0 To UBound(SArr): B(i) = SArr(i): Next
InitByteArray = B
End Function

Dim x() as byte
x = InitByteArray("1,2,3")
x = InitByteArray("&H1,&H2,&H3")
x = InitByteArray("1, 2, 3")
all 3 Lines result in the same ByteValues

Olaf


Bob Butler

2005-12-12, 6:56 pm

"Schmidt" <sss@online.de> wrote in message
news:uR7RY9y$FHA.264@tk2msftngp13.phx.gbl
> "Randy Birch" <rgb_removethis@mvps.org> schrieb im Newsbeitrag
> news:O8BAMSt$FHA.1312@TK2MSFTNGP09.phx.gbl...
>
>
> TypeName(x(0)) would result with 'Integer' not 'Long' in this case
> (implicit Autocasting below 5 Hex-Digits gives Integer).
>
> Regarding the problem:
> I would put a simple function into a Basic-Module:
>
> Function InitByteArray(strByteValues As String) As Byte()


you can simplify a bit by using ParamArray

Private Sub Main()
Dim x() As Byte
'both Lines result in the same ByteValues
x = InitByteArray(1, 2, 3)
x = InitByteArray(&H1, &H2, &H3)
End Sub

Function InitByteArray(ParamArray BytesIn()) As Byte()
Dim i As Long
Dim B() As Byte
ReDim B(0 To UBound(BytesIn))
For i = 0 To UBound(BytesIn)
B(i) = BytesIn(i)
Next
InitByteArray = B
End Function


--
Reply to the group so all can participate
VB.Net: "Fool me once..."

Boki

2005-12-12, 6:56 pm

The original source is Java, J2ME. :)

Best regards,
Boki.

"Bob Butler" <tiredofit@nospam.com>
???????:OYOOtLy$FHA.3096@tk2msftngp13.phx.gbl...
> "Randy Birch" <rgb_removethis@mvps.org> wrote in message
> news:u%234wt%23s$FHA.328@TK2MSFTNGP14.phx.gbl
>
>
> 'short' is 'Integer' in VB isn't it? Or is the original source not C++?
>
> --
> Reply to the group so all can participate
> VB.Net: "Fool me once..."
>



Boki

2005-12-12, 6:56 pm

Great.

Best regards,
Boki.

"Schmidt" <sss@online.de> 撰寫於郵件新聞:uR7RY9y$FHA.264@tk2msftngp13.phx.gbl...
>
> "Randy Birch" <rgb_removethis@mvps.org> schrieb im Newsbeitrag
> news:O8BAMSt$FHA.1312@TK2MSFTNGP09.phx.gbl...
>
>
> TypeName(x(0)) would result with 'Integer' not 'Long' in this case
> (implicit
> Autocasting below 5 Hex-Digits gives Integer).
>
> Regarding the problem:
> I would put a simple function into a Basic-Module:
>
> Function InitByteArray(strByteValues As String) As Byte()
> Dim i As Long, SArr() As String, B() As Byte
> SArr = Split(strByteValues, ",")
> If UBound(SArr) < 0 Then Exit Function
> ReDim B(UBound(SArr))
> For i = 0 To UBound(SArr): B(i) = SArr(i): Next
> InitByteArray = B
> End Function
>
> Dim x() as byte
> x = InitByteArray("1,2,3")
> x = InitByteArray("&H1,&H2,&H3")
> x = InitByteArray("1, 2, 3")
> all 3 Lines result in the same ByteValues
>
> Olaf
>
>



Boki

2005-12-12, 6:56 pm

Thanks a lot, I will try it.

Best regards,
Boki.

"Rick Rothstein [MVP - Visual Basic]" <rickNOSPAMnews@NOSPAMcomcast.net> 撰寫於郵件新聞:%23GF12Ju$FHA.3944@TK2MSFTNGP10.phx.gbl...
>
> By the way, if you are willing to do a little pre-string manipulation,
> this
> can be simplified a little bit...
>
> In the Immediate Window, execute this code
>
> ? Chr$(&H1) & Chr$(&H2) & Chr$(&H3) & Chr$(&H4)
>
> That will print out four "unprintable" characters which VB will represent
> by
> showing 4 small boxes next to each other. These four boxes are a proper
> string consisting of the characters with ASCII values of 1, 2, 3 and 4.
> Simply Copy them into the Clipboard and then Paste them into the
> assignment
> line I posted earlier in place of the concatenated Chr$ function calls.
> This
> will produce this code...
>
> Dim b() As Byte
> b = StrConv("", vbFromUnicode)
>
> I'm not sure if the ASCII values inside of the quotes will survive the
> posting process or not, but you can try copying the code above and see. In
> any case, String constants consisting of unprintable characters can be
> produced in the manner I described above.
>
> Rick
>
>



Randy Birch

2005-12-12, 6:56 pm

Hi Bib ...

Since he asked for a byte array in the subject I assumed his tool's version
of short was byte. Its possible his use of "byte array" was incorrect with
respect to that meaning under VB.

--

Randy Birch
MS MVP Visual Basic
http://vbnet.mvps.org/
----------------------------------------------------------------------------
Read. Decide. Sign the petition to Microsoft.
http://classicvb.org/petition/
----------------------------------------------------------------------------



"Bob Butler" <tiredofit@nospam.com> wrote in message
news:OYOOtLy$FHA.3096@tk2msftngp13.phx.gbl...
: "Randy Birch" <rgb_removethis@mvps.org> wrote in message
: news:u%234wt%23s$FHA.328@TK2MSFTNGP14.phx.gbl
: > dim b(0 to 3) as byte
:
: >> private final short[] Reg ={ 0x01, 0x02, 0x03, 0x04 };
:
: 'short' is 'Integer' in VB isn't it? Or is the original source not C++?
:
: --
: Reply to the group so all can participate
: VB.Net: "Fool me once..."
:

Bob Butler

2005-12-12, 6:56 pm

"Randy Birch" <rgb_removethis@mvps.org> wrote in message
news:eYjf3X0$FHA.344@TK2MSFTNGP11.phx.gbl
> Hi Bib ...
>
> Since he asked for a byte array in the subject I assumed his tool's
> version of short was byte. Its possible his use of "byte array" was
> incorrect with respect to that meaning under VB.


True, and since it's Java and not C++ as I had mistakenly assumed it could
be a byte; I'm not sure what 'short' means to Java. The suggestions made
pretty much still apply anyway just by using the correct data type.

--
Reply to the group so all can participate
VB.Net: "Fool me once..."

Michael C

2005-12-12, 6:56 pm

"Rick Rothstein [MVP - Visual Basic]" <rickNOSPAMnews@NOSPAMcomcast.net>
wrote in message news:%23GF12Ju$FHA.3944@TK2MSFTNGP10.phx.gbl...
> Dim b() As Byte
> b = StrConv("", vbFromUnicode)
>


Hi Rick,

Have a look at this site, it gives tips on writing unmaintainable code. I
don't think your technique is there but it would be an excellent addition.
:-)

http://thc.org/root/phun/unmaintain.html

Michael


Michael C

2005-12-12, 6:56 pm

"Randy Birch" <rgb_removethis@mvps.org> wrote in message
news:u%234wt%23s$FHA.328@TK2MSFTNGP14.phx.gbl...
> dim b(0 to 3) as byte
>
> b(0) = &H1
> b(1) = &H2
> b(2) = &H3
> b(3) = &H4


Hi Boki,

For christ sake ignore everything in this thread except for randy's reply
above.

Michael


Karl E. Peterson

2005-12-12, 6:56 pm

Michael C wrote:
> "Randy Birch" <rgb_removethis@mvps.org> wrote in message
> news:u%234wt%23s$FHA.328@TK2MSFTNGP14.phx.gbl...
>
> Hi Boki,
>
> For christ sake ignore everything in this thread except for randy's
> reply above.


Unless it's a huge array, in which case the above would be pretty tedious.
In that case, something more like this might be useful:

http://vb.mvps.org/articles/ap199912.asp

--
Working without a .NET?
http://classicvb.org/


Rick Rothstein [MVP - Visual Basic]

2005-12-12, 6:56 pm

> Have a look at this site, it gives tips on writing unmaintainable code. I
> don't think your technique is there but it would be an excellent addition.
> :-)
>
> http://thc.org/root/phun/unmaintain.html


LOL. Look, I worked for the same company for 32-1/2 years before retiring...
how do you think I could have managed that without using some creative
coding techniques across the years.<vbg>

Okay, look... the first code I posted was in response to Randy saying it
couldn't be done in one-line of code. Now, as anyone who has followed my
posting history on these newsgroups knows, that was a challenge I just
couldn't refuse.<g> The second piece of code (which I issued a
correction/clarification for by the way) was an extension built on top of
the first piece of code. As to maintainability or even readability... the OP
asked for a one-line piece of code for a problem that had a very simple
multi-line solution... with a request like that, readability and
maintainability were apparently not high on his list of concerns.... so I
didn't let it bother me either.<bg>

Rick


Michael C

2005-12-12, 6:56 pm

"Rick Rothstein [MVP - Visual Basic]" <rickNOSPAMnews@NOSPAMcomcast.net>
wrote in message news:eG1CMg2
> LOL. Look, I worked for the same company for 32-1/2 years before
> retiring...
> how do you think I could have managed that without using some creative
> coding techniques across the years.<vbg>


My employer specifically asks me to write unmaintainable code. Not in those
exact words of course but discourages documentation or any form of
standard/coordination/communication between developers. :-)

> Okay, look... the first code I posted was in response to Randy saying it
> couldn't be done in one-line of code. Now, as anyone who has followed my
> posting history on these newsgroups knows, that was a challenge I just
> couldn't refuse.<g> The second piece of code (which I issued a
> correction/clarification for by the way) was an extension built on top of
> the first piece of code. As to maintainability or even readability... the
> OP
> asked for a one-line piece of code for a problem that had a very simple
> multi-line solution... with a request like that, readability and
> maintainability were apparently not high on his list of concerns.... so I
> didn't let it bother me either.<bg>


I realise most of the posters here wouldn't use the techniques they posted
but it looked like Boki might be taking the ideas seriously :-)

Michael


Michael C

2005-12-12, 6:56 pm

"Karl E. Peterson" <karl@mvps.org> wrote in message
news:uoHWxe2$FHA.436@TK2MSFTNGP10.phx.gbl...
> Unless it's a huge array, in which case the above would be pretty tedious.
> In that case, something more like this might be useful:
>
> http://vb.mvps.org/articles/ap199912.asp


That's true, I was assuming it was a small array, which might not be
correct.

Michael


Schmidt

2005-12-13, 6:56 pm


"Bob Butler" <tiredofit@nospam.com> schrieb im Newsbeitrag
news:OE8aGMz$FHA.3928@tk2msftngp13.phx.gbl...

> you can simplify a bit by using ParamArray...


Yep, thats even nicer for direct typing - only drawback is - this way you
cannot initialize from (String-)Constants.

Olaf


Phill W.

2005-12-15, 6:55 pm


"Boki" <bokiteam@ms21.hinet.net> wrote in message
news:%23jfHLNt$FHA.504@TK2MSFTNGP12.phx.gbl...
> Can I write them in a single line ?


Of course ;-)

dim b(0 to 3) as byte : b(0) = &H1 : b(1) = &H2 : b(2) = &H3 : b(3) = &H4

> Could you please advice the read/data method?
> e.g. Data 1,2,3,4,5


Read and Data are not supported in VB6.

HTH,
Phill W.


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com