Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > microsoft.public.scripting.vbscript > #12436
| From | Ulrich Möller <knobbi38@arcor.de> |
|---|---|
| Newsgroups | microsoft.public.scripting.vbscript |
| Subject | Re: Access the 3rd and rest elements of a Byte() (byte array)? |
| Date | 2022-03-11 11:23 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <t0f7uf$v3c$1@dont-email.me> (permalink) |
| References | <7ikpiwc1wlb3.1jl0fbkule7nk$.dlg@40tude.net> <t07aqg$1ipv$2@gioia.aioe.org> <t07kg2$2b4$1@dont-email.me> |
Am 08.03.2022 um 14:07 schrieb Mayayana:
> "R.Wieser" <address@not.available> wrote
>
> | To access each character (byte?) in a string you need to use a
> mid(arr,i,1)
> |
>
> I don't think it's possible with straight VBS because it's
> looking for a variant. You can take the byte data and
> walk the position, reading 1 byte at a time. With that it's
> possible to get a, b, c, d, etc. But that only works as long
> as you don't actually look at it programmatically. If you
> read 1 byte at position 4 into x, you can do MsgBox x and
> get "e". But you can't touch "e". It's datatype byte array.
> You can't convert it. You can't get to it as x(0). Because
> it's not a variant.
option explicit
dim ds, arr, i, n, h
stop
set ds = createobject("adodb.stream")
ds.open
ds.charset = "windows-1252"
ds.writetext "AaBbCc"
ds.position = 0
ds.type = 1
arr = ds.read
for i = 0 to ubound(arr)
n = ascb(midb(arr,i+1,1))
h = cint(n)
wscript.echo h
next
With these lines I have no problem to access the array byte by byte. n
is of type byte and can be converted arbitrarily. The trick is to use
MidB().
Uriclh
Back to microsoft.public.scripting.vbscript | Previous | Next — Previous in thread | Next in thread | Find similar
Access the 3rd and rest elements of a Byte() (byte array)? JJ <jj4public@gmail.com> - 2022-03-08 06:24 +0700
Re: Access the 3rd and rest elements of a Byte() (byte array)? "R.Wieser" <address@not.available> - 2022-03-08 11:22 +0100
Re: Access the 3rd and rest elements of a Byte() (byte array)? "Mayayana" <mayayana@invalid.nospam> - 2022-03-08 08:07 -0500
Re: Access the 3rd and rest elements of a Byte() (byte array)? "R.Wieser" <address@not.available> - 2022-03-08 21:15 +0100
Re: Access the 3rd and rest elements of a Byte() (byte array)? "Mayayana" <mayayana@invalid.nospam> - 2022-03-08 16:57 -0500
Re: Access the 3rd and rest elements of a Byte() (byte array)? JJ <jj4public@gmail.com> - 2022-03-09 10:58 +0700
Re: Access the 3rd and rest elements of a Byte() (byte array)? "R.Wieser" <address@not.available> - 2022-03-09 10:39 +0100
Re: Access the 3rd and rest elements of a Byte() (byte array)? Ulrich Möller <knobbi38@arcor.de> - 2022-03-11 11:23 +0100
Re: Access the 3rd and rest elements of a Byte() (byte array)? "R.Wieser" <address@not.available> - 2022-03-11 13:14 +0100
Re: Access the 3rd and rest elements of a Byte() (byte array)? "Mayayana" <mayayana@invalid.nospam> - 2022-03-11 09:12 -0500
Re: Access the 3rd and rest elements of a Byte() (byte array)? Ulrich Möller <knobbi38@arcor.de> - 2022-03-11 18:41 +0100
Re: Access the 3rd and rest elements of a Byte() (byte array)? "Mayayana" <mayayana@invalid.nospam> - 2022-03-11 15:58 -0500
Re: Access the 3rd and rest elements of a Byte() (byte array)? JJ <jj4public@gmail.com> - 2022-03-12 06:24 +0700
Re: Access the 3rd and rest elements of a Byte() (byte array)? "Mayayana" <mayayana@invalid.nospam> - 2022-03-11 19:30 -0500
csiph-web